Knit to word doc

That error message means R tried to run the is.factor() function, but the var object didn't exist. And another function may have thrown that error message.

With the amount of information supplied it's really hard to give more help than that.

I would really encourage you to review the following guide, FAQ: Tips for writing R-related questions.
For example, the guide emphasizes asking coding questions with formatted code-chunks and a reprex.