eval(expr,envir,enclos)中的错误:object' Gender'未找到

时间:2016-04-13 13:53:39

标签: r

我从.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 ...

0 个答案:

没有答案