How can I calculate a two-month rolling mean, if the two-months windows are not of equal length? Preferably in datatable
. Sample code:
set.seed(24)
test <- data.table(x = rnorm(762),time=seq(as.Date("1988/03/15"), as.Date("1990/04/15"), "day"))
So here, the first mean would be from 1988/03/15 until 1988/04/30, the second one from 1988/04/01 until 1988/05/31, and so on. The data availability in each month can be of different length, by intention.
RcppRoll
. Worked wonders for bigger data – 5th