[R] partial cumsum

smu ml at z107.de
Wed Nov 11 18:25:52 CET 2009


On Wed, Nov 11, 2009 at 08:53:50AM -0800, William Dunlap wrote:
> 
> Perhaps
>    > ave(x, rev(cumsum(rev(is.na(x)))), FUN=cumsum)
>     [1]  1  3  6 NA  5 11 18 26 35 45
> 

it takes some time to understand how it works, but it's perfect.

thank you,
 stefan




More information about the R-help mailing list