Get sliding window indices

ts_windower(
  y,
  win = length(y),
  step = NA,
  overlap = NA,
  adjustY = NA,
  alignment = c("r", "c", "l")[1],
  silent = TRUE
)

Arguments

y

A time series or numeric vector

win

Size of the window to slide across y

step

Size of steps between windows. Can be larger than win, but is ignored if overlap is not NA.

overlap

A value between [0 .. 1]. If overlap is not NA (default), the value of step is ignored and set to floor(overlap*win). This produces indices in which the size of step is always smaller than win, e.g. for fluctuation analyses that use binning procedures to represent time scales.

adjustY

If not NA, or, FALSE a list object with fields that match one or more arguments of ts_trimfill (except for x,y), e.g. list(action="trim.NA",type="end",padding=NA,silent=TRUE). See Return value below for details.

alignment

Whether to right ("r"), center ("c"), or left ("l") align the window.

silent

Silent mode.

Value

If adjustY is a list object with fields that represent arguments of ts_trimfill, then the (adjusted) vector y is returned with an attribute "windower". This is a list object with fields that contain the indices for each window that fits on y, given win, step or overlap and the settings of adjustY. If adjustY = NA, only the list object is returned. An attribute time is returned with the time index based on the alignment arguments.

See also