[R] Using xtable with summaries of lm objects
Peter Dunn
dunn at usq.edu.au
Tue Jun 22 02:02:16 CEST 2004
Hi all
Suppose I do the following:
set.seed(1000)
library(xtable)
x <- runif( 10 )
y <- 1 + 2*x + rnorm( length(x) )
test.lm <- lm( y ~ x )
summary( test.lm )
xtable ( summary( test.lm ) )
The final xtable output follows:
% latex table generated in R 1.8.1 by xtable 1.2-2 package
% Tue Jun 22 09:56:36 2004
\begin{table}[ht]
\begin{center}
\begin{tabular}{rrrrr}
\hline
& Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\
\hline
(Intercept) & 0.5731 & 0.4396 & 1.30 & 0.2286 \\
x & 1.9680 & 0.8894 & 2.21 & 0.0578 \\
\hline
\end{tabular}
\end{center}
\end{table}
Notice this line:
& Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\
This will not LaTeX correctly, as teh string `$$' occurs;
presumably it should read something like:
& Estimate & Std. Error & t value & Pr({$>$}{$|$}t$|$) \\
or (better IMHO):
& Estimate & Std. Error & $t$ value & Pr($>|t|$) \\
I searched the archives, and couldn't find any reference to this
bug; perhaps its just me! Is there a known workaround (as I want
to auto-generate these table using Sweave; I know I could
cut-and-paste the table, and correct as appropriate).
Thanks as always.
P.
> version
_
platform i686-pc-linux-gnu
arch i686
os linux-gnu
system i686, linux-gnu
status
major 1
minor 8.1
year 2003
month 11
day 21
language R
--
Dr Peter Dunn (USQ CRICOS No. 00244B)
Web: http://www.sci.usq.edu.au/staff/dunn
Email: dunn @ usq.edu.au
Opinions expressed are mine, not those of USQ. Obviously...
More information about the R-help
mailing list