rolling_apply_static: Apply Rolling Function (Static Version)

Description Usage Arguments See Also Examples

View source: R/rolling_apply.R

Description

Apply a function to the time series values in a sequence of user-defined, half-open time windows.

Usage

1
2
rolling_apply_static(x, start_times, end_times, FUN, ..., align = "right",
  interior = FALSE)

Arguments

x

a numeric time series object.

start_times

a POSIXct object of strictly increasing time points, specifying the start times of the time windows.

end_times

a POSIXct object of strictly increasing time points, of same length as start_times, and with start_times[i] <= end_times[i] for each 1 <= i <= length(start_times). Specifies the end times of the time windows.

FUN

a function to be applied to the vector of observation values inside each half-open time interval (start_times[i], end_times[i]].

...

arguments passed to FUN.

align

either "right" (the default), "left", or "center". Specifies the position of each output time inside the corresponding time window.

interior

logical. If TRUE, only include time windows [start_times[i], end_times[i]] in the output that are in the interior of the temporal support of x, i.e. in the interior of the time interval [start(x), end(x)].

See Also

rolling_apply for a version of this function that dynamically determines the time windows.

Examples

1
2
3
4
5
6
start_times <- seq(as.POSIXct("2007-11-08"), as.POSIXct("2007-11-09 12:00:00"), by="12 hours")
end_times <- start_times + dhours(8)
rolling_apply_static(ex_uts(), start_times, end_times, FUN=mean, interior=TRUE)
rolling_apply_static(ex_uts(), start_times, end_times, FUN=mean)
rolling_apply_static(ex_uts(), start_times, end_times, FUN=mean, align="left")
rolling_apply_static(ex_uts(), start_times, end_times, FUN=mean, align="center")

andreas50/utsOperators documentation built on May 25, 2019, 7:16 a.m.