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@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.

Reply via email to