Error in eval(expr, envir, enclos) : object not found

前端 未结 4 1339
傲寒
傲寒 2020-12-08 05:45

I cannot understand what is going wrong here.

data.train <- read.table(\"Assign2.WineComplete.csv\",sep=\",\",header=T)
# Building decision tree
Train &l         


        
4条回答
  •  鱼传尺愫
    2020-12-08 05:50

    Don't know why @Janos deleted his answer, but it's correct: your data frame Train doesn't have a column named pre. When you pass a formula and a data frame to a model-fitting function, the names in the formula have to refer to columns in the data frame. Your Train has columns called residual.sugar, total.sulfur, alcohol and quality. You need to change either your formula or your data frame so they're consistent with each other.

    And just to clarify: Pre is an object containing a formula. That formula contains a reference to the variable pre. It's the latter that has to be consistent with the data frame.

提交回复
热议问题