[R] ask for help how to get accumulate contingency table?

From: alex chin <rfrqchin_at_hotmail.com>
Date: Tue, 18 Mar 2008 09:41:54 -0400

Hi, I post the question again.
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 tr
2 1 1
4 0 1
3 1 1
2 1 1
4 1 1
3 1 1
2 0 1
4 0 1
3 0 1
2 0 1
4 0 1
3 1 1
3 0 2
2 0 2
>table(data1)

 tr = 1

    y
x 0 1
  2 2 2
  3 1 3
  4 3 1
tr = 2

    y
x 0 1
  2 2 2
  3 2 2
  4 1 3
Question: How to get accumulate contingency table by variable "tr" in data1? e.g. how to get the following results. tr = 1

    y
x 0 1
  2 2 2
  3 1 3
  4 3 1
tr = 2

     y
x 0 1
 2 4 4
 3 3 6
 4 4 4
...
Thank you for your help. xj.



Helping your favorite cause is as easy as instant messaging. You IM, we give.

        [[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 Tue 18 Mar 2008 - 14:03:30 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 Tue 18 Mar 2008 - 14: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