I trained my machine learning model using training dataset via a document term matrix.
I am trying to predict my test dataset but unfortunately it contains words that the training dataset does not come with.

My question is how do I actually remove those words in my test dataset that is not found in the training dataset.

I am using tm package and I created a DocumentTermMatrix.