Re: [R] applying cumsum within groups

2015-04-03 Thread peter dalgaard
ave() is your friend (unfortunately named as it may be): > ave(dat$seq, dat$ts, FUN=cumsum) [1] 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 1 1 1 1 1 1 1 2 2 2 2 2 2 2 1 1 1 [39] 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 > On 03 Apr 2015, at 14:17 , Morway, Eric wrote: > > This small example will be

Re: [R] applying cumsum within groups

2015-04-03 Thread David Winsemius
On Apr 3, 2015, at 5:17 AM, Morway, Eric wrote: > This small example will be applied to a problem with 1.4e6 lines of data. > First, here is the dataset and a few lines of R script, followed by an > explanation of what I'd like to get: > > dat <- read.table(textConnection("ISEG IRCH val > 1

[R] applying cumsum within groups

2015-04-03 Thread Morway, Eric
This small example will be applied to a problem with 1.4e6 lines of data. First, here is the dataset and a few lines of R script, followed by an explanation of what I'd like to get: dat <- read.table(textConnection("ISEG IRCH val 11 265 12 260 13 234 54 39 467 54 40