rolling_time_window_indices: Rolling Time Window Indices

Description Usage Arguments Value Examples

View source: R/rolling_apply.R

Description

For a sorted sequence of time points, determine the start and end indices inside a half-open (open on the left, closed on the right) rolling time window.

Usage

1
rolling_time_window_indices(times, start_times, end_times)

Arguments

times

a POSIXct object of strictly increasing time points.

start_times

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

end_times

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

Value

A list with two integer vectors of equal length, specifying the start and end index in times of each rolling time window. If the start index is larger than the end index, that means that no observation lies in the corresponding time window.

Examples

1
2
3
tmp <- rolling_time_window(start="2015-01-01", end="2015-06-30", width=ddays(90), by=ddays(30))
times <- seq(as.POSIXct("2014-12-01"), as.POSIXct("2015-12-30"), by="week")
rolling_time_window_indices(times, tmp$start_times, tmp$end_times)

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