I have used this code to perform a 5 fold cross-validation on the Davis dataset found in the carData library.
install.packages("caret")
library(caret)
trainControl<-trainControl(method="cv",number=5)
lm<-train(weight~height+repht+repwt,Davis,method="lm",trControl=trainControl)
lm
Running this I obtain the error saying that there are missing values for weight. This is the error message:
Error in na.fail.default(list(weight = c(77L, 58L, 53L, 68L, 59L, 76L, : missing values in object
I would be very grateful for any suggestions on how to solve this problem. Thanks in advance!