Skip to content
Prev 170179 / 398506 Next

Table Formatting

Harold,

xtable() does not handle multicol's AFAICS. Short of hand coding this,
which would not be hard, you can use Frank's latex() function in the
Hmisc package.

Something along the lines of the following will get close.

install.packages("Hmisc", dependencies = TRUE)
library(Hmisc)
?latex

# Presuming that the source data is in a dataframe called 'DF'

latex(DF, file = "DF.tex",
      title = "",
      rowname = NULL,
      cgroup = c("", "SNA1", "SNA2", "SNA3"),
      n.cgroup = c(1, 2, 2, 2),
      colheads = c("", "Year", rep(c("TACC", "Catch"), 3)))


This give you the DF.tex TeX file that I have attached and to which I
manually added the preamble and \end{document} directives.

I am also attaching a PDF of the resultant table for easy review.

If you wanted to have the second line only going over the column pairs
rather than all of the columns, replace the line:

  \tabularnewline \cline{1-10}

with:

  \tabularnewline
  \cline{3-4}
  \cline{6-7}
  \cline{9-10}


See the DF2.* files attached. I did not see away to do that in the
function arguments, but perhaps I missed something.

Frank has more information here:

  http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/StatReport

HTH,

Marc Schwartz
on 02/11/2009 02:30 PM Doran, Harold wrote:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DF.pdf
Type: application/pdf
Size: 11938 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090211/30c83065/attachment-0004.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DF2.pdf
Type: application/pdf
Size: 11973 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090211/30c83065/attachment-0005.pdf>