Re: [R] Adding dash-lines in R tables

From: Ista Zahn <izahn_at_psych.rochester.edu>
Date: Sun, 22 May 2011 11:23:12 -0400

Axel, you may also be interested in the ascii function (in the ascii package). The ascii version of David's example is

library(ascii) #may need install.packages("ascii") first ascii(M)
ascii(table(sample(1:10, 100, replace=TRUE)))

Best,
Ista
On Sun, May 22, 2011 at 9:52 AM, David Winsemius <dwinsemius_at_comcast.net> wrote:
>
> On May 22, 2011, at 7:47 AM, Axel Urbiz wrote:
>
>> is it possible to add dash lines to tables or matrices when they are
>> printed? An example of what I'm looking for is this:
>>
>> library(Design)
>> y <- sample(c(0,1),100, replace = TRUE)
>> x <- rnorm(100)
>> summary(y ~ x)
>
> There is a method for summary on formula objects found by typing
>
> methods(summary)   # didn't find the answer looking at code of
> summary.formula.
>
> Then there is a print method for summary.formula objects>
>
> methods(print)
> # examine the 3 print.summary. .... methods
> # didn't find the answer there, either, but did notice that the
> # function `print.char.matrix` was being used near the end of the code
>
>> M <- matrix(letters[1:10], 2)
>> print.char.matrix(M)
> +-+-+-+-+-+
> |a|c|e|g|i|
> +-+-+-+-+-+
> |b|d|f|h|j|
> +-+-+-+-+-+
>
> It is in package Hmisc and its behavior is documented:
>
> ?print.char.matrix
>
>> print.char.matrix( table(sample(1:10, 100, replace=TRUE) )  )
> +--+--+
> | 1|12|
> +--+--+
> | 2| 6|
> +--+--+
> | 3|11|
> +--+--+
> | 4|13|
> +--+--+
> | 5|12|
> +--+--+
> | 6| 7|
> +--+--+
> | 7| 8|
> +--+--+
> | 8| 8|
> +--+--+
> | 9|14|
> +--+--+
> |10| 9|
> +--+--+
>
> --
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> 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

______________________________________________
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.
Received on Sun 22 May 2011 - 15:25:48 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 22 May 2011 - 18:40:08 GMT.

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

list of date sections of archive