[R] query on xtable output
ManuelPerera-Chang@fmc-ag.com
ManuelPerera-Chang at fmc-ag.com
Tue Oct 25 16:13:58 CEST 2005
Dear all,
I am exporting to latex a matrix via xtable. My matrix includes e.g. 4 rows
and 4 columns. The first two rows containing real values(e.g. a laboratory
parameter's mean value), and the two rows at the bottom containing only
integers (number of cases).
>
mymat<-matrix(c(c(10.52,2.52,12.35,3.63),c(3.52,16.25,13.62,6.36),c(11,12,15,16),c(14,15,16,18)),4,4,byrow=TRUE)
> mymat
[,1] [,2] [,3] [,4]
[1,] 10.52 2.52 12.35 3.63
[2,] 3.52 6.25 3.62 6.36
[3,] 11.00 12.00 15.00 16.00
[4,] 14.00 15.00 16.00 18.00
>
trend_table<-xtable(mymat,caption="Caption",display=c('s','fg','fg','fg','fg'),size='small')
The R help on xtable states that "fg" displays 'digits' as number of
_significant_ digits. As a result no decimal places are shown in the last
two rows, as I wanted, but no decimal places are shown neither in the first
two rows, if the real value in the cell is greater than 10, and only 1
decimal place if the value in the cell is lower than 10.
Thus I got the following Latex output: ...
> trend_table
\begin{table}[ht]
\begin{center}
\begin{tabular}{rrrrr}
\hline
& 1 & 2 & 3 & 4 \\
\hline
1 & 11 & 2.5 & 12 & 3.6 \\ I would like to have more decimal places here
e.g. 10.5 or 10.52 instead of 11.
2 & 3.5 & 16 & 14 & 6.4 \\
3 & 11 & 12 & 15 & 16 \\ This is what I expect, no commas and decimal
0-s for the number of cases.
4 & 14 & 15 & 16 & 18 \\
\hline
\end{tabular}
\caption{Caption}
\end{center}
\end{table}
I would prefer to show 1 additional decimal in both cases.
Thus my question is how to modify the setting for _significant_ digits(in
xtable??) in order to print the correctly formated values.
Sorry for reposting my question, ...
Thank you
Manuel
More information about the R-help
mailing list