"You can't use macro parameter character # in vertical mode"

I've finished a project for university and the only step left is to compute a pdf document with my r script. At an earlier time I used knitr (stitch('myproject.R') to do this, which worked just fine, however at this point, R Studio will only give out a .tex document. I think this is due to the error "You can't use macro parameter character # in vertical mode" which I'm getting all over. I don't know what this means and how to fix it.

Any help is much appreciated! Note that my r skills are very very basic and my Latex skills non-existent.

Thank you!