[R] partial cumsum

smu ml at z107.de
Wed Nov 11 16:58:04 CET 2009


Hello,

I am searching for a function to calculate "partial" cumsums.

For example it should calculate the cumulative sums until a NA appears,
and restart the cumsum calculation after the NA.

this:

x <- c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10)

should become this:

1 3 6 NA 5  11  18  26  35  45


any ideas?

thank you and best regards,

    stefan




More information about the R-help mailing list