4

我有一个错误

library(mlr)
library(dplyr)
tree <- read.csv("file.csv",  header = T,  na.strings=c("", "NA")) 

tree$hipo = as.factor(tree$группы==1) # this variable has 3 levels i want to get 2
df = select(tree, - группы)
trainTask <- makeClassifTask( data = df,target = "hipo")

我明白了

Error in makeClassifTask(data = df, target = "hipo") : 
  Assertion on 'data' failed: Columns must be named according to R's variable naming rules.

然后我做如下

tree <- read.csv("file.csv",  header = T,  na.strings=c("", "NA")) 
tree$группы = as.factor(tree$группы==1)
trainTask <- makeClassifTask( data = tree,target = "группы")

这是正确的!那么问题出在select? 我尝试用一​​个玩具示例重现这一点

df = data.frame('пер'= c(1,0,2,0,1,2), 'b' = c(1,1,0,0,1,0), 'c' = c(1,1,0,0,1,0))
str(df)
df$d = as.factor(df$пер==1)
df1 = select(df, - пер)
trainTask <- makeClassifTask( data = df1,target = "d")

这是正确的!可能是什么问题呢?西里尔名字?我检查了名字make.names

4

0 回答 0