我从.csv文件中读取数据,并运行以下命令
plsFit <- train(CollegePlans ~ .,data = training,method = "pls",preProc = c("center", "scale"));
toPredict <- c("Female",35800,124,"Not Encouraged","Does not plan to attend")
plsClasses <- predict(plsFit, newdata = toPredict)
并得到以下错误
Error in eval(expr, envir, enclos) : object 'Gender' not found
这是一个结构:
str(training)
'data.frame': 5401 obs. of 5 variables:
$ Gender : Factor w/ 2 levels "Female","Male": 2 1 1 2 1 1 1 1 2 1 ...
$ ParentIncome : int 53900 24900 65800 11440 16700 47630 39820 4860 65340 66550 ...
$ IQ : int 118 87 93 117 102 100 127 95 100 112 ...
$ ParentEncouragement: Factor w/ 2 levels "Encouraged","Not Encouraged": 1 2 2 1 2 1 1 1 1 1 ...
$ CollegePlans : Factor w/ 2 levels "Does not plan to attend",..: 2 1 1 2 1 2 2 1 1 2 ...