Skip to contents

Supply one pair of offsets per window. Negative offsets are before the reference time, zero is the reference time, and positive offsets are after it. The start is included and the end is excluded. Windows may overlap and are returned in input order.

Usage

define_windows(intervals, reference_col = NULL)

Arguments

intervals

Non-empty list of numeric pairs. Each pair contains a finite start and end, with the start strictly before the end. Optional list names are used as labels and must be unique and non-blank. Unnamed pairs get labels that encode their offsets, as in make_windows().

reference_col

Optional name of the reference timestamp column. It is stored on the result for window_pane().

Value

A data frame with relative_start, relative_end, width, and label. Use it with window_pane(), scan_windows(), or plot_window_pane(). Set the time unit when calculating summaries.

Examples

define_windows(list(c(-15, -10), c(-11, -3)))
#>   relative_start relative_end width          label
#> 1            -15          -10     5 window_m15_m10
#> 2            -11           -3     8 window_m11_m03
define_windows(list(early = c(-15, -10), late = c(-11, -3)))
#>   relative_start relative_end width label
#> 1            -15          -10     5 early
#> 2            -11           -3     8  late