How to include percent symbol in header using Sweave in R

I am trying to use Sweave to create a statistical report, and I am trying to put the header on xtable, however, if I include the percent sign, this will break things.

Sample code example

<<label=Analyte2_Results, results=tex, echo=FALSE>>= print(xtable(result[[2]], caption=paste(levels(vardata$Analyte)[1], " percent bias and precision estimates with 95 \% confidence intervals",sep="")), tabular.environment='longtable', latex.environments=c("center"), floating=FALSE, include.rownames=FALSE) @ 

If I use% or \%, then the Sweave process works, but Latex does not, if I try \%, then Sweave will fail. There seems to be no alternative way to specify a percent symbol in latex

Is there a way to put a percent symbol in the header?

+6
r sweave latex xtable
source share
1 answer

Try to โ€œslip awayโ€ from the โ€œescapeโ€ statement so that it survives Sweaving to get into the LaTeX file (i.e. \\% ). This is because LaTeX "%" needs the escape operator "\". For example, when I recently called several rows and columns of a table, I had to use:

 row.names(table.a) <- c("ARCH(1)", "~") colnames(table.a) <- c("$\\omega$", "$\\alpha_{1}$", "Q(1)", "Q(12)") 
+9
source share

All Articles