I want to export a latex table with a units column that has the percent (%) symbol.
library(xtable)
foo <- data.frame(units='%', citation = '\\citep{authorYYYYabc}')
print(xtable(foo), sanitize.text.function = function(x) {x})
note: above code has been changed since Joris' answer.
In this case, the '%' is interpreted as a comment by LaTeX.
I have tried
gsub('%', '\\%', foo)
returns
[1] "1"
how can I convert the % to \% so that LaTex comments it out?
This question is a little bit like a previous question "can R paste('\')?"; even polishing the same table, but I can't figure out this particular case.