I am still looking for an efficient way to get accumulated contingency table.
Becasue it is huge data and permutate with covariate. it will be very slow if
I use loops. Can somebody give me a help? Thanks.
xj> Date: Tue, 18 Mar 2008 10:43:27 -0400> From: markleeds@verizon.net>
Subject: RE: [R] ask for help how to get accumulate contingency table?> To:
rfrqchin@hotmail.com> > I'm not at work so I'm not sure it will
work but you can try below.> > I am assuming the result of table(data1) is
a list so> > tablelist<-table(data1)> >
cumtablelist<-list()> > for ( tablenum in (2:length(tablelist)) {>
> >
cumtablelist[[tablenum]]<-cumtablelist[[tablenum-1]]+cumtablelist[[tablenum]>
]> > }> > print(cumtablelist)> > > > > -----Original
Message-----> From: r-help-bounces@r-project.org
[mailto:r-help-bounces@r-project.org] On> Behalf Of alex chin> Sent:
Tuesday, March 18, 2008 9:42 AM> To: r-help@r-project.org> Subject: [R]
ask for help how to get accumulate contingency table?> > > 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]]> >
_________________________________________________________________
Helping your favorite cause is as easy as instant messaging. You IM, we give.
[[alternative HTML version deleted]]