[R] cumsum list..

Julian Burgos jmburgos at u.washington.edu
Thu Mar 13 18:57:05 CET 2008


In this case you can simply do

cumsum(a[x,]+a[y,])

Julian


yoooooo wrote:
> Hi all, i have the following.. 
> 
> a <- data.frame(data = seq(1,10))
> 
> i have indices:
> x <- c(1, 5, 3, 9)
> y <- c(2, 7, 4, 10)
> 
> I want the cumsum of a[1:2], a[5:7], a[3:4]... 
> 
> is there an elegant way to do it without any loop? Thanks!
>



More information about the R-help mailing list