[R] Rearranging long tables, Sweave, xtable, LaTeX

Ista Zahn istazahn at gmail.com
Thu Nov 12 11:45:07 CET 2009


Yeah, I've had this kind of situation before. Usually I first see if I
can fit it on the page by rotating it and/or reducing the size. If
that doesn't do it then I'll re-arrange as you suggest. Basically the
print method is just wrapping the output after n columns (27 in my
case, but I think this depends on the options you have set). So you
can do this wrapping yourself before calling xtable:

tmp <- with(expand.grid(Fact1 = 1:3, Fact2 = 1:40), table(Fact1, Fact2))
tmp2 <- rbind(tmp[,1:20], tmp[,21:40])
xtable(tmp2)

Hope it helps,

Ista


On Thu, Nov 12, 2009 at 4:20 AM, Ottorino-Luca Pantani
<ottorino-luca.pantani at unifi.it> wrote:
> Dear R-users,
> consider the two following outputs, ## 1 and  ## 2
>
>
> \begin{Scode}{Setup, echo = FALSE, print = FALSE, eval = TRUE}
> with(expand.grid(Fact1 = 1:3, Fact2 = 1:40), table(Fact1, Fact2))
>        ## 1
> xtable(with(expand.grid(Fact1 = 1:3, Fact2 = 1:40), table(Fact1, Fact2)))
>   ## 2
> \end{Scode}
>
> The first line
> with(expand.grid(Fact1 = 1:3, Fact2 = 1:40), table(Fact1, Fact2))
> has an output that easily fit the A4 page, while the second produce
> an output that do not fit the A4 page.
>
>
> Is it possible to produce an output with xtable, but similar to the one of
> the first line ?
> In other words I do not want to use \longtables and the similar.
>
> Where should I look for info ?
> In Latex ? In Sweave ? In xtable ?
>
> Thanks a lot
>
> --
> Ottorino-Luca Pantani, Università di Firenze
> Dip. Scienza del Suolo e Nutrizione della Pianta
> P.zle Cascine 28 50144 Firenze Italia
> Tel 39 055 3288 202 (348 lab) Fax 39 055 333 273
> OLPantani at unifi.it http://www4.unifi.it/dssnp/
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org




More information about the R-help mailing list