Is there a way to repeat the top row / set headers when generating an xtable with a longtable option ?
For eg., if I have
tableSb <- xtable(df, caption="A Very Long Table", label="ALongTable")
print(tableSb, include.rownames=TRUE, tabular.environment="longtable", floating=FALSE)
This works fine, but when the tables roll over into a new page the headers are not repeated. Any suggestions ?
Looking at the code for print.xtable, the only considerations it makes when
tabular.environment="longtable"
arefloating=TRUE
It does not emit the code specific for repeating the headers on subsequent pages. Check out
latex
in theHmisc
package. I know it has support for longtables as well, but I don't recall if it repeats headers correctly.In order to accomplish this, you'll need to use the
add.to.row
option of theprint
function (run?print.xtable
for more information).Try this (adapted from https://r-forge.r-project.org/tracker/?func=detail&atid=4864&aid=1627&group_id=1228)
It's a bit clumsy of a solution, but at least it'll provide you with plenty of customization.