我有错误
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