I wish to execute a function FUN
over a rolling window of 1 year
. My xts has not the same number of points per year. How can I do that in an efficient way?
P.S. usually to execute a FUN
over a fixed number of datapoints (for instance 100) I use:
as.xts(rollapply(data = zoo(indicator), FUN = FUN, width = 100, align = "right"))
but obviously this doesn't work if there are not always the same number of points per year.