[R] Compiling a contingency table of counts by case

hadley wickham h.wickham at gmail.com
Fri Sep 22 18:33:00 CEST 2006


> what's different from:
>  > with(dat, tapply(x, list(name,case), sum))
>        1  2  3
> Joe   1  1 NA
> John NA  1 NA
> Karl NA NA  0
> Mike  1  0  1
>
> and how to deal with this table ?

Well, the syntax is easier (once you have the data in the correct,
molten, form), and more flexible for other tasks.  It is surely better
to learn a general purpose tool rather than a tool for a specific
task.

To use that table to answer the original question, you just need to
look column by column for the desired patterns of 0's and 1's, eg. in
case 1, Joe, Mike and Zoe all had ones.   Perhaps I misunderstood the
original question.

Hadley



More information about the R-help mailing list