[Tex/LaTex] knitr sanitises the % marker for LaTex comments and they show up in the final document

knitrrxtable

I am writing a knitr document using xtable to get my tables. Xtable inserts by default a comment saying:

 "latex table generated in R 3.1.0 by stable 1.7-3 package % Thu Sep 18 14:19:21 2014"

This text is obviously commented out by a % symbol in xtable's output, but knitr seems to be sanitising the % by inserting a escape character "\" before it, which then is picked up by pdfLatex, resulting in the text:

% latex table generated in R 3.1.0 by xtable 1.7-3 package % Thu Sep 18 14:19:21 2014

Can I stop either knitr or xtable from doing this?

Edit: Here is an example document.

---
title: "knitr document"
output:
pdf_document:
keep_tex: yes
number_sections: yes
toc: yes
---
```{r load_packages,echo=FALSE,include=FALSE,results='hide',cache=TRUE}
library(xtable)
```
```{r prepare_table,echo=FALSE,results='hide'}
table <- cbind(c(1,2,3,4),c(1,2,3,4))
colnames(table) <- c("var1","var2")
```
```{r print_table,echo=FALSE,results='asis'}
print(xtable(table,include.colnames=TRUE))
```

Best Answer

Thanks to @Tyler, I went browsing the knitr issues page and learned that xtable has an argument to suppress the comments (upvote to Tyler for that). It is a bit hard to use because you have to pass the argument to xtable's print method. The code that solves my problem looks like:

print(xtable(table,include.colnames=TRUE),comment=FALSE)