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

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Sun, 22 May 2011 09:52:41 -0400

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.
Received on Sun 22 May 2011 - 13:56:21 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 - 15: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