Hmisc latex() and Rcmdr numSummary() percentage issues
Dear R users, I have issues regarding latex() from Hmisc and numSummary() from Rcmdr. Here's an example:
library(Rcmdr)
data(Angell, package="car")
numSummary(Angell[,"hetero"], statistics=c("mean", "sd", "quantiles"), quantiles=c( 0,.25,.5,.75,1 ))
.numSummary <- popOutput()
latex(as.table(.numSummary$table), cdec=c(2), file="", title="")
The resulting LaTeX code (see below) is not compilable, because of the
`%' signs present in the column headers, and that are not escaped by
latex() (contrary to the behaviour of xtable()). I can solve the issue
manually by escaping the percentage signs `\%'.
Would there be a way to automatise this?
Thank you,
Liviu
######## Uncompilable LaTeX ########
% latex.default(as.table(.numSummary$table), cdec = c(2), file = "",
title = "")
%
\begin{table}[!tbp]
\begin{center}
\begin{tabular}{lrrrrrrr}\hline\hline
\multicolumn{1}{l}{}&
\multicolumn{1}{c}{mean}&
\multicolumn{1}{c}{sd}&
\multicolumn{1}{c}{0%}&
\multicolumn{1}{c}{25%}&
\multicolumn{1}{c}{50%}&
\multicolumn{1}{c}{75%}&
\multicolumn{1}{c}{100%}
\\ \hline
&$31.37$&$20.41$&$10.6$&$16.9$&$23.7$&$39$&$84.5$\\
\hline
\end{tabular}
\end{center}
\end{table}
######## End of LaTeX ########
######## Compilable LaTeX ########
% latex.default(as.table(.numSummary$table), cdec = c(2), file = "",
title = "")
%
\begin{table}[!tbp]
\begin{center}
\begin{tabular}{lrrrrrrr}\hline\hline
\multicolumn{1}{l}{}&
\multicolumn{1}{c}{mean}&
\multicolumn{1}{c}{sd}&
\multicolumn{1}{c}{0\%}&
\multicolumn{1}{c}{25\%}&
\multicolumn{1}{c}{50\%}&
\multicolumn{1}{c}{75\%}&
\multicolumn{1}{c}{100\%}
\\ \hline
&$31.37$&$20.41$&$10.6$&$16.9$&$23.7$&$39$&$84.5$\\
\hline
\end{tabular}
\end{center}
\end{table}
######## End of LaTeX ########
Do you know how to read? http://www.alienetworks.com/srtest.cfm Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail