Error in predicting raster with randomForest, Caret, and factor variables
问题 I am trying to predict a raster layer with randomForest and the caret package, but fail when I introduce factor variables. Without factors, everything works fine, but as soon as I bring a factor in, I get the error: Error in predict.randomForest(modelFit, newdata) : Type of predictors in new data do not match that of the training data. I have created some sample code below that walks through he process. I present it in a few steps for transparency and to provide a working example. (To skip