[R] Rolling window difference for zoo time series
Eric Berger
er|cjberger @end|ng |rom gm@||@com
Tue Apr 24 21:01:25 CEST 2018
Zoo_TS/lag(Zoo_TS) - 1
On Tue, Apr 24, 2018 at 9:29 PM, Christofer Bogaso <
bogaso.christofer using gmail.com> wrote:
> 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,
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list