Displaying 1 result from an estimated 1 matches for "runsum2".
Did you mean:
  runsum
  
2004 Nov 19
9
Running sum
I have vector X of length N that I want to have a running sum for 
(called Y).  I just need max(Y).  I do this with a "for" loop like so:
     Y <- vector(length=N)
     Y[1] <- X[1]
     for (i in 2:N) {
       Y[i] <- Y[i-1]+X[i]
     }
     return(max(Y))
Is there a faster way to do this?
Thanks,
Sean