简体   繁体   English

在 R 中使用 rpart Package,错误选择决策树的所有变量 model

[英]Using rpart Package in R, error selecting all variables for decision tree model

I'm trying to create a decision tree model using a dataset with 200+ variables and I'm getting this error in using the.我正在尝试使用具有 200 多个变量的数据集创建决策树 model,但在使用 . notation for all variables.所有变量的符号。

fit <- rpart(first_party ~ ., data=train)
Error in `[.data.frame`(m, labs) : undefined columns selected

The tree models fine when I define the variables by name, but I can't do that 200 times.当我按名称定义变量时,树模型很好,但我不能那样做 200 次。

fit <- rpart(first_party ~ Crime + Number_of_Schools + Pop_Total, data=train)

It seemed to be the \ in one of the variable names.它似乎是其中一个变量名称中的 \。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM