[R] how to get accumulate contingency table

From: alex chin <rfrqchin_at_hotmail.com>
Date: Mon, 17 Mar 2008 16:47:53 -0400

Hi, all. I got a lot of help from the this mailing list, it save me a lot of time. Here is my question. x<-rep(c(2,3,4),20)y<-sample(rep(c(0,1),30))tr<-rep(c(1:5),6)data1<-data.frame(x,y,tr)data1<-data1[order(data1$tr),]> data1 x y tr1 2 0 16 4 1 111 3 0 116 2 0 121 4 0 126 3 1 131 2 0 136 4 1 141 3 0 146 2 0 151 4 0 156 3 0 12 3 0 27 2 0 212 4 0 2....... table(data1) > table(data1), , tr = 1 yx 0 1 2 4 0 3 3 1 4 2 2, , tr = 2 yx 0 1 2 3 1 3 3 1 4 2 2....Question: How to get accumulate contingency table by variable "tr" in data1? e.g. how to get the following results., , tr = 1 yx 0 1 2 4 0 3 3 1 4 2 2, , tr = 2 yx 0 1 2 7 1 3 6 2 4 4 4... Thank you for your help. xj.

Shed those extra pounds with MSN and The Biggest Loser! Learn more.



Climb to the top of the charts! Play the word scramble challenge with star power.

        [[alternative HTML version deleted]]



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 Mon 17 Mar 2008 - 20:52:12 GMT

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 Mon 17 Mar 2008 - 22:30:22 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