[R] Extract vector elements until cumsum <= x

Dgnn sharkbrainpdx at gmail.com
Mon Jan 4 04:02:39 CET 2010


Hi All,

I have a vector n, and for each n[i] I want to extract n[i], n[i+1],
n[i+2]..., until the cumulative sum of n[i] and subsequent elements exceeds
a CheckValue, whereupon I move to the next index and repeat. 

I am trying to find a Vectorized approach, and have seen similar posts where
filter{stat} and rollmean{zoo} were suggested, but, I haven't been able to
figure a way to use them for this problem.

Best wishes to all, and thanks for the help!

Dgnn


-- 
View this message in context: http://n4.nabble.com/Extract-vector-elements-until-cumsum-x-tp998023p998023.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list