On Jul 23, 2011, at 13:11 , Simon Kiss wrote:
> Dear colleagues, I have a data set that looks roughly like this;
> mydat<-data.frame(state=c(rep("Alabama", 5), rep("Delaware", 5),
> rep("California", 5)), news=runif(15, min=0, max=8), cum.news=rep(0, 15))
>
> For each state, I'd like to cumulat
Hi Simon,
Is this what you want?
mydat$cum.news<-unlist(tapply(mydat$news,mydat$state,FUN=cumsum))
Weidong Gu
On Sat, Jul 23, 2011 at 7:11 AM, Simon Kiss wrote:
> Dear colleagues, I have a data set that looks roughly like this;
> mydat<-data.frame(state=c(rep("Alabama", 5), rep("Delaware", 5),
Dear colleagues, I have a data set that looks roughly like this;
mydat<-data.frame(state=c(rep("Alabama", 5), rep("Delaware", 5),
rep("California", 5)), news=runif(15, min=0, max=8), cum.news=rep(0, 15))
For each state, I'd like to cumulatively sum the value of "news" and make that
put that valu
3 matches
Mail list logo