[Rd] Margins on tables

BXC (Bendix Carstensen) bxc at steno.dk
Tue Mar 2 16:56:58 MET 2004


> -----Original Message-----
> From: Duncan Murdoch [mailto:dmurdoch at pair.com] 
> Sent: Tuesday, March 02, 2004 3:13 PM
> To: BXC (Bendix Carstensen)
> Cc: r-devel at stat.math.ethz.ch
> Subject: Re: [Rd] Margins on tables
> 
> 
> On Tue, 2 Mar 2004 14:20:01 +0100, "BXC (Bendix Carstensen)" 
> <bxc at steno.dk> wrote :
> 
> >It has long been a nuisance to me not being able to form margins on 
> >multiway tables in a simple fashion, so i wrote margins().
> >
> >In my opinion it should go into the base package. The code and the 
> >documentation is in:
> >
> >http://www.biostat.ku.dk/~bxc/R/margins/
> >
> >Please help yourself, and enhance and rename as you see fit.
> 
> I really like the idea of this (and in fact was planning to 
> work on something similar, when I had time).
> 
> A couple of comments:
> 
> It would be nice if the label for the added margin matched 
> the name of the function, even when "FUN=fun" was used 
> instead of "FUN = list(name=fun)".

I wanted to do this, but in R when you have a single object as argument
you can
retrieve its name by the deparse(substitute())-trick, but if the
function is just
given as part of a list element there is no way (thai I know of) to get
at its 
name. You can of course do the deparse(substitute())-trick, and embark
on major 
text-processing to get you the name.

> 
> It might be nice to be able to add some lines to the tables 
> (though this is more of an ftable request than a margins 
> request, the modifications will probably have to be done 
> together).  So for example the table 
> 
>           Sea Black Dead Red White Min Max
> Aye  Bee                                  
> Oui  Buzz         3    7   9     6   3   9
>      Hum         12   10   8     7   7  12
> Si   Buzz        10    9   7     9   7  10
>      Hum          5    9   3     6   3   9
> Yes  Buzz         0   10   5     5   0  10
>      Hum         12    8   9     8   8  12
> Sum  Buzz        13   26  21    20  13  26
>      Hum         29   27  20    21  20  29
> 
> could be displayed as
> 
>           Sea | Black Dead Red White | Min Max
> Aye  Bee      |                      |        
> ----------------------------------------------
> Oui  Buzz     |     3    7   9     6 |   3   9
>      Hum      |    12   10   8     7 |   7  12
> Si   Buzz     |    10    9   7     9 |   7  10
>      Hum      |     5    9   3     6 |   3   9
> Yes  Buzz     |     0   10   5     5 |   0  10
>      Hum      |    12    8   9     8 |   8  12
> ----------------------------------------------   
> Sum  Buzz     |    13   26  21    20 |  13  26
>      Hum      |    29   27  20    21 |  20  29
> 
> (Fixed pitch fonts required!)
> 

Good you did not ask for the Bee margins too...

When I use the unsurpassed tabulation feature in SAS, proc tabulate,
I always use the options:  " formchar='          ' noseps ". 
If you know what they do you know why I did not implement your
suggestion.

The thing you want is an xtable function for an ftable object, so you
can 
get a nice readable LaTeX table with all the \multicolumn and \cline
bells 
and whistles. I'm sitting here for someone to produce it...

Best,
Bendix

> Duncan



More information about the R-devel mailing list