[R] formatting tables with long column names via package:xtable within Sweave

Jonathan Baron baron at psych.upenn.edu
Thu Jul 15 13:08:03 CEST 2004

On 07/15/04 11:07, john.gavin at ubs.com wrote:
>I use the excellent Sweave tools for writing documents
>but was wondering how to neatly print a data.frame
>with long column headings.
>I cant manage to do this via package:xtable.

I think a problem with xtable is this:

> xtable(d1,align=c("|l|","c","c","c","c|"))
Error in "align<-.xtable"(`*tmp*`, value = switch(1 +
is.null(align),  : 
		 "align" must be containing elements of

So the align attribute won't accept p(1cm) either, for example,
but this might not be the best solution anyway.  It seems just as
easy to modify your table after xtable makes it than to modify
xtable to allow such things, since xtable would not save you any
typing time.  You could stick in your long headers using
\multicolumn{1}{p(2cm)}{blah blah blah}, or \parbox{}, or just
use two rows.  (I haven't tested any of this.)

Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page:            http://www.sas.upenn.edu/~baron
R search page:        http://finzi.psych.upenn.edu/

More information about the R-help mailing list