I've been using the RcppRoll package to do rolling sums, but I'd like to find a function/option that would allow me to turn a vector like this [1 2 3 4 5]
into [1 3 6 9 12]
for a window of 3, for instance.
Currently, I've been using roll_sum, which returns
[NA NA 6 9 12]
for a window of 3.
It seems like it would work to use something like rollapplyr(x, 3, sum, partial=TRUE)
, but that's just far too slow for something I'll eventually need to run on millions of rows.