I have a dataset (training - testing) with missing data and I would like to impute data before the classification.
I tried using the caret package and the function preProcess, I want to impute data using the predictor variable for the training set and impute data on the testing set only using the knowledge of the trainingset without using the predictor of the testing set (that I should not know).
p = preProcess(x = training, method = "knnImpute", k = 10)
pred = predict(object = p, newdata = training)
pred1 = predict(object = p, newdata = testing)
when I run this code, I have this error on the second line
Error in FUN(newX[, i], ...) :
cannot impute when all predictors are missing in the new data point
I also tried to remove the predictor variable in the training set but the result is the same. I tried using the Iris dataset, removing some value in each column and removing the predictor and it works...but the datasets are with the same characteristics, both data.frame and both only with numeric values.
sessionInfowill help get your question answered. - topepo