[R] Rolling window difference for zoo time series

Christofer Bogaso bog@@o@chri@tofer @ending from gm@il@com
Tue Apr 24 20:29:20 CEST 2018


Hi,

I have a 'zoo' time series as below :

Zoo_TS = zoo(5:1, as.Date(Sys.time())+0:4)

Now I want to calculate First order difference of order 1, rolling
window basis i.e.

(Zoo_TS[2] - Zoo_TS[1] ) / Zoo_TS[1]
(Zoo_TS[3] - Zoo_TS[2] ) / Zoo_TS[2]
.....

Is there any direct function available to achieve this?

Thanks,




More information about the R-help mailing list