[R] Sweave & xtable

Thomas Lumley tlumley at u.washington.edu
Thu Jan 8 23:53:05 CET 2004


On Thu, 8 Jan 2004, michaell taylor wrote:
> I have successfully incorporated simple graphics and outputs, but am
> having trouble getting a latex (xtable) table to function properly.
> Latex is seemingly treating the xtable code as input or verbatim text.
> That is, if I run Sweave('myfile.Snw', echo=T) I get the latex syntax
> xtable code handed to me twice in the myfile.dvi.  Turning echo off, I
> get the xtable code (not the nicely formated latex table) back in the
> dvi.
>

A quick look through some of my Sweave files produced the snippet
------
The \code{xtable} package produces HTML and \LaTeX\ formatted tables
<<echo=false,fig=false,results=tex>>=
library(xtable)
data(tli)
tli.table <- xtable(tli[1:10,])
digits(tli.table)[c(2,6)] <- 0
print(tli.table)
@
-------
so it looks like results=tex is what you want.

	-thomas




More information about the R-help mailing list