A similar question was asked however the link in the answer points to random forest example, it doesn\'t seem to work in my case.
Here is an example what I\'m trying
As topepo explained above, the function is getting confused by the variable names being generated.
If you run:
make.names(levels(traintestClass_subset))
and the result is different to how you have labelled the classes in your outcome variable than this issue will occur. Just make sure names generated by the piece of code above align with the class names you have provided to your factor and it should work.