title: R Caret Package error imputing data with Pre-Process function
body: <p>I have a dataset (training - testing) with missing data and I would like to impute data before the classification.</p>
  
  <p>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>
  
  <pre><code>p = preProcess(x = training, method = "knnImpute", k = 10)
  pred = predict(object = p, newdata = training)
  pred1 = predict(object = p, newdata = testing)
  </code></pre>
  
  <p>when I run this code, I have this error on the second line</p>
  
  <pre><code>Error in FUN(newX[, i], ...) : 
    cannot impute when all predictors are missing in the new data point
  </code></pre>
  
  <p>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.</p>