Although the tutorial you quote has the Species
column in the test
set, it is not needed by the predict
function as you guessed:
library(randomForest)
test <- iris[ c(1:10, 51:60, 101:110), -5] # removed the Species column here.
train <- iris[ c(11:50, 61:100, 111:150), ]
r <- randomForest(Species ~., data=train, importance=TRUE, do.trace=100)
predict(r, test)