I think the best answer to this question is below: Column names on each page using xxtable in Sweave
What if you want to edit the table in R? The solution above edits the output, so you will not need to add these lines to your long code manually. So this works better:
print(test.big, tabular.environment='longtable', include.colnames = TRUE, floating=FALSE, add.to.row = list(pos = list(0), command = "\\hline \\endhead "))
Note that you can add multiple arguments to the add.to.row list:
print(test.big, tabular.environment='longtable', include.colnames = TRUE, floating=FALSE, list(pos = list(seq(1,nrow(get(groups[i])), by = 2), 0), command = c("\\rowcolor[gray]{.95} ","\\hline \\endhead ")))
You need to add this to your Sweave file:
\usepackage{colortbl}
This creates a gray fill for every second line and title for each page.
Mikko
source share