Re: [R] Compiling a contingency table of counts by case

From: hadley wickham <h.wickham_at_gmail.com>
Date: Fri 22 Sep 2006 - 16:33:00 GMT

> 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



R-help@stat.math.ethz.ch 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 Sat Sep 23 02:37:15 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 22 Sep 2006 - 17:30:19 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.