search for: cp11

Displaying 1 result from an estimated 1 matches for "cp11".

Did you mean: c11
2013 Feb 01
29
cumulative sum by group and under some criteria
...ml-node+s789695n4657196h87@n4.nabble.com> wrote: > Hi, > Try this: > colnames(d)<-c("m1","n1","x1","y1","p11","p12") > library(zoo) > res1<- do.call(rbind,lapply(lapply(split(d,list(d$m1,d$n1)),function(x) > {x$cp11[x$x1>1]<- cumsum(x$p11[x$x1>1]);x$cp12[x$y1>1]<- > cumsum(x$p12[x$y1>1]);x}),function(x) > {x$cp11<-na.locf(x$cp11,na.rm=F);x$cp12<- na.locf(x$cp12,na.rm=F);x})) > #there would be a warning here as one of the list element is NULL. The, > warning is okay > row...