[R] Custom LaTeX tables
Werner Wernersen
pensterfuzzer at yahoo.de
Wed Feb 27 23:59:42 CET 2008
Thanks for the answers! I will play around a bit and
maybe I really need to write a custom wrapper than.
Best,
Werner
--- Gabor Grothendieck <ggrothendieck at gmail.com>
schrieb:
> On Tue, Feb 26, 2008 at 10:58 AM, Werner Wernersen
> <pensterfuzzer at yahoo.de> wrote:
> > Hello,
> >
> > I am very happy that I have Sweave and R to write
> my
> > papers. But I still have to do some tables by hand
> > since I have not found out how I can customize the
> > latex tables produced by R further (I mainly use
> > xtable()). Like for instance, I have a table which
> > needs an extra row every few rows as a group
> header
> > and sometimes I want some extra horizontal lines
> in
> > the table and also a multicolumn heading.
> >
> > How do you guys cope with such cases, do you set
> the
> > table by hand in the end or have you found a neat
> way
> > to deal with this?
> >
> > Many thanks and regards,
> > Werner
>
> A few options are:
>
> - Hmisc latex() supports multicolumn headings and
> group headings
> although the large number of arguments may be
> daunting
>
> - xtable (and Hmisc's latex too) supports a style of
> combining
> latex fragments with the xtable. The add.to.row=
> argument on
> print.xtable is the
> one to notice. e.g. using the builtin BOD data frame
> this adds a 2nd row
> of headings and a group heading:
>
> print(xtable(BOD, align = "r|r|r|"),
> include.rownames = FALSE,
> add.to.row = list(pos = list(0, 3),
> command = c("\\multicolumn{1}{|c|}{(days)} &
> \\multicolumn{1}{|c|}{(mg/l)} \\\\ ",
> "\\hline \\multicolumn{2}{|l|}{Special
> Values} \\\\ \\hline ")))
>
> - given the freedom from restrictions I find its
> often just best to
> do it manually in latex or if you have many tables
> with the same format
> in a report to generate a report-specific table
> layout wrapper that emits
> the latex you need.
>
More information about the R-help
mailing list