[R] how to get accumulate contingency table

From: alex chin <rfrqchin_at_hotmail.com>
Date: Mon, 17 Mar 2008 16:20:12 -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.  



[[elided Hotmail spam]]

        [[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:38:52 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 - 21:30:21 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