0
$\begingroup$

I'm building a model and i want to re preocess the data using PCA but i have an error in the train function :

library(kernlab)
library(e1071)
data(spam)

inTrain <- createDataPartition(y=spam$type,p=0.75, list=FALSE)
training <- spam[inTrain,]
testing <- spam[-inTrain,] 
# construct model 
modelFit <- train(training$type ~ .,method="glm",preProcess="pca",data=training)
# print results of model 
confusionMatrix(testing$type,predict(modelFit,testing))

when i run the code i got this error :

Error in `[.data.frame`(data, , all.vars(Terms), drop = FALSE) : 
  undefined columns selected
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.