[Tex/LaTex] Multiple Tables Sweave/Latex

rsweave

I am very new to LaTeX and Sweave but am excited that it may make my life much simpler when combined with R.

What I am looking to do: Create multiple crosstabs, most likely in a loop. As a result, the number of tables will not be determined ahead of time and I am hoping to have a page break in between each. Lastly, for the time being, I am looking to make this a report instead of a presentation (Beamer).

My question: I assume this is possible, but is it easier to do in Sweave or LaTeX and how should I get started. I have had some bumps in the road getting up and running, but I have been able to compile some very basic examples of both.

This would be my first document in LaTeX, so I am open to any and all suggestions.

Best Answer

Have a look at the xtable package, which prints LaTeX tables neatly. I have used this a lot for Sweave auto-generated reports.

The following is a toy example of printing some tables for LaTeX in a Sweave document

<<echo=FALSE,print=FALSE,results=tex>>
## generate an example set of tables                                                                                                                         
library(xtable)
data(tli)
my.tables <- list()
for(iTable in 1:20){
 my.tables[[iTable]] <- tli[1:20 + iTable,]
}

## print these out, with page breaks in between                                                                                                              
for(iTable in 1:20){
  print(xtable(my.tables[[iTable]]))
  cat('\\clearpage\n')
}
@