Description Usage Arguments Details Methods (by class) References Examples
View source: R/rolling_apply_specialized.R
This function provides a fast, specialized implementation of rolling_apply
for certain choices of FUN
and for by=NULL
(i.e. when moving the rolling time window one observation at a time, rather than by a fixed temporal amount).
1 2 3 4 5 | rolling_apply_specialized(x, ...)
## S3 method for class 'uts'
rolling_apply_specialized(x, width, FUN, align = "right",
interior = FALSE, ...)
|
x |
a numeric time series object with finite, non-NA observation values. |
width |
a finite, positive |
FUN |
a function to be applied to the vector of observation values inside the half-open (open on the left, closed on the right) rolling time window. |
align |
either |
interior |
logical. Should time windows lie entirely in the interior of the temporal support of |
... |
further arguments passed to or from methods. |
It is usually not necessary to call this function, because it is called automatically by rolling_apply
whenever a specialized implementation is available.
uts
: Implementation for "uts"
objects with finite, non-NA observation values.
Eckner, A. (2017) Algorithms for Unevenly Spaced Time Series: Moving Averages and Other Rolling Operators.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | rolling_apply_specialized(ex_uts(), dhours(12), FUN=length)
rolling_apply_specialized(ex_uts(), dhours(12), FUN=length, align="center")
rolling_apply_specialized(ex_uts(), dhours(12), FUN=length, align="left")
rolling_apply_specialized(ex_uts(), dhours(12), FUN=length)
rolling_apply_specialized(ex_uts(), dhours(12), FUN=length, interior=TRUE)
# Rolling sum
rolling_apply_specialized(ex_uts(), ddays(1), FUN=sum)
rolling_apply_specialized(ex_uts(), ddays(1), FUN=sum) - rolling_apply(ex_uts(), ddays(1), FUN=sum)
# Rolling min/max
rolling_apply_specialized(ex_uts(), ddays(1), FUN=min)
rolling_apply_specialized(ex_uts(), ddays(1), FUN=max)
# Rolling prodcut
rolling_apply_specialized(ex_uts(), ddays(0.5), FUN=prod)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.