Re: [R] how to print table with more columns per row?

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Fri 21 Jul 2006 - 02:20:10 EST

In some cases it may be sufficient to abbreviate the colnames:

> library(MASS); data(survey)
> head(survey)

     Sex Wr.Hnd NW.Hnd W.Hnd Fold Pulse Clap Exer Smoke Height M.I

1 Female   18.5   18.0 Right  R on L    92    Left Some Never 173.00   Metric
2   Male   19.5   20.5  Left  R on L   104    Left None Regul 177.80 Imperial
3   Male   18.0   13.3 Right  L on R    87 Neither None Occas     NA     <NA>
4   Male   18.8   18.9 Right  R on L    NA Neither None Never 160.00   Metric
5   Male   20.0   20.0 Right Neither    35   Right Some Never 165.00   Metric
6 Female   18.0   17.7 Right  L on R    64   Right Some Never 172.72 Imperial
     Age
1 18.250
2 17.583
3 16.917
4 20.333

5 23.667
6 21.000
> local({ colnames(survey) <- abbreviate(colnames(survey), 3); head(survey)})
     Sex Wr.H  NW.  W.Hn     Fld Pls     Clp  Exr   Smk    Hgh      M.I    Age
1 Female 18.5 18.0 Right  R on L  92    Left Some Never 173.00   Metric 18.250
2   Male 19.5 20.5  Left  R on L 104    Left None Regul 177.80 Imperial 17.583
3   Male 18.0 13.3 Right  L on R  87 Neither None Occas     NA     <NA> 16.917
4   Male 18.8 18.9 Right  R on L  NA Neither None Never 160.00   Metric 20.333
5   Male 20.0 20.0 Right Neither  35   Right Some Never 165.00   Metric 23.667
6 Female 18.0 17.7 Right  L on R  64   Right Some Never 172.72 Imperial 21.000

On 7/20/06, ryszard.czerminski@novartis.com <ryszard.czerminski@novartis.com> wrote:
> When printing a table it is broken at some point (depending how long are
> the associated names)
> >>> see example below.
>
> Is there a way to control number of columns being printed for a given
> chunk of the table?
>
> Best regards,
> Ryszard
>
> > z5
> AAAAAAA BBBBBBB CCCCCCC DDDDDDD EEEEEEE FFFFFFF GGGGGGG HHHHHHH
> IIIIIII
> AAAAAAA 1.00 -0.69 -0.54 -0.88 NA NA NA NA
> -0.88
> BBBBBBB -0.69 1.00 0.65 0.82 NA NA NA 1
> 0.83
> CCCCCCC -0.54 0.65 1.00 0.49 NA NA NA NA
> 0.94
> DDDDDDD -0.88 0.82 0.49 1.00 NA NA NA 1
> 0.90
> EEEEEEE NA NA NA NA NA NA NA NA
> NA
> FFFFFFF NA NA NA NA NA NA NA NA
> NA
> GGGGGGG NA NA NA NA NA NA NA NA
> NA
> HHHHHHH NA 1.00 NA 1.00 NA NA NA 1
> NA
> IIIIIII -0.88 0.83 0.94 0.90 NA NA NA NA
> 1.00
> JJJJJJJ NA NA NA NA NA NA NA NA
> NA
> KKKKKKK 0.05 0.21 0.11 -0.11 NA NA NA 1
> NA
> LLLLLLL 0.73 -0.68 -0.16 -0.91 NA NA NA -1
> -0.35
> JJJJJJJ KKKKKKK LLLLLLL
> AAAAAAA NA 0.05 0.73
> BBBBBBB NA 0.21 -0.68
> CCCCCCC NA 0.11 -0.16
> DDDDDDD NA -0.11 -0.91
> EEEEEEE NA NA NA
> FFFFFFF NA NA NA
> GGGGGGG NA NA NA
> HHHHHHH NA 1.00 -1.00
> IIIIIII NA NA -0.35
> JJJJJJJ NA NA NA
> KKKKKKK NA 1.00 0.24
> LLLLLLL NA 0.24 1.00
> >
>
> CONFIDENTIALITY NOTICE\ \ The information contained in this ...{{dropped}}
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>



R-help@stat.math.ethz.ch 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. Received on Fri Jul 21 02:24:58 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 21 Jul 2006 - 04:18:06 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.