So, I'm using downloadHandler to create a report, and as advised in an example I found on the net, I've created a .Rmd file that servers as a template.
xtable(mydata)
prints mydata nicely, but the comments that xtable generates are being printed on the final output, complete with their initial % signs.
Is there a way to tell that TeX comments should be treated as comments?
We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.
If you've never heard of a reprex before, you might want to start by reading this FAQ:
As noted in the linked answer in @dlsweet's reply, print(xtable(mydata), comment=FALSE) will get rid of the latex timestamp comment. Also, to prevent xtable from the adding the timestamp comment ever, after you load the xtable package, run options(xtable.comment=FALSE). Then you can just do xtable(mydata) from then on.
For creating tables more generally, there are a few other options that take much of the pain out of custom-formatting latex table output. For example:
kable (from the knitr package) along with the kableExtra package for custom formatting.