[R] Adding dash-lines in R tables

David Winsemius dwinsemius at comcast.net
Sun May 22 21:09:15 CEST 2011


On May 22, 2011, at 2:41 PM, David Winsemius wrote:

>
> On May 22, 2011, at 2:22 PM, David Hajage wrote:
>
>> moreover:
>> > library(ascii)
>
> Seems strange that the ascii.interger function doesn't set the  
> digits argument to 0:
>
ascii.integer

> > ascii(as.integer(c(3,4,5)))
> |=====================
> | 3.00 | 4.00 | 5.00
> |=====================
>
> > ascii(as.integer(c(3,4,5)), digits=0)
> |============
> | 3 | 4 | 5
> |============
>

I should have added that I do appreciate your drawing this package to  
our attention, since it seems to have a large number of supported  
classes which should make it very useful.

Two questions:

  I am hoping there might be parameters that could be set so that a  
more "mathematical" version of matrix-class might be produced:

| 1.00  3.00 |
| 2.00  4.00 |

Rather than:

|==============
| 1.00 | 3.00
| 2.00 | 4.00
|==============

I see by running the help examples in print.ascii that some  
standardized type arguments have been designed. Where should I look to  
see how to design other user-defined types? IAfter looking at the  
help(package=ascii) and help() for several of the functions I am  
guessing that I might find that asciidoc is a format that is elsewhere  
described?
-- 
David.
> -- 
> a different David.
>> > M <- matrix(letters[1:10], 2)
>> > M
>>    [,1] [,2] [,3] [,4] [,5]
>> [1,] "a"  "c"  "e"  "g"  "i"
>> [2,] "b"  "d"  "f"  "h"  "j"
>> > ascii(M)
>> |====================
>> | a | c | e | g | i
>> | b | d | f | h | j
>> |====================
>> > print(ascii(M), "rest")
>>
>> +---+---+---+---+---+
>> | a | c | e | g | i |
>> +---+---+---+---+---+
>> | b | d | f | h | j |
>> +---+---+---+---+---+
>> > print(ascii(M), "pandoc")
>>
>> --- --- --- --- ---
>> a   c   e   g   i
>> b   d   f   h   j
>> --- --- --- --- ---
>>
>> You could also try "t2t", "org", or "textile", and then set a  
>> global option:
>> > options(asciiType = "youroutputtype")
>>
>> david
>> 2011/5/22 Ista Zahn <izahn at psych.rochester.edu>:
>> > 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.
>> >
>>
>
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list