@sangameshks wrote:
Hi all,
I have been facing an error in R and I am finding it difficult to find a solution for the same. please help me out.
the code and error as followsknn.train<-train(ytrain~.,data=xtrain,method=“knn”,trControl=control1,tuneGrid=grid1)
Error in[.data.frame(data, , all.vars(Terms), drop = FALSE) :
undefined columns selectednow the crux of the problem is: I had a test on knn with k=1,2,3; and it was perfect, without any error. I was interested in cross-validation and when I did the same. I received this error above.
Additional information: I have separated ytrain data; ytrain is a factor with 2 levels. when I check nrow(ytrain) it say NULL. Later I tried to change it to as.data.frame and retried the same. yet it is not working. help me out
Posts: 1
Participants: 1