caret dummyVars on unseen data I created my dummy variables, trained my model and tested it as below:  

dummy &lt;- dummyVars(formula = CLASS_INV ~ ., data = campaign_spending_final_imputed) 
campaign_spending_final_dummy &lt;- predict(dummy, newdata = campaign_spending_final_imputed) %&gt;% as.data.frame() %&gt;%
  mutate(CLASS_INV = campaign_spending_final$CLASS_INV) 


I now want to test my process on an unseen real world data. How can I do it? How can I encode the category class to its respective dummy encoding?
The predict function will work on the new data.  It has some options for how to handle entries that don't appear in the original data's labels.

https://rdrr.io/cran/caret/man/dummyVars.html