rendering a html file

we can't diagnose from such a vague statement.
What does it say ? you can copy and paste the error.
format it as code for readability.

Guessing
Common errors, when knitting arise from not making the knittable script self contained. knitting happens in its own environment so you need to add whatever data loading / data prep into your script as steps.