roll: Generate rolling windows

Description Usage Arguments Value Methods (by class)

Description

Generate resample objects of rolling windows over elements of a data frame.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
roll(data, ...)

## S3 method for class 'data.frame'
roll(data, width = 1L, align = c("left", "right",
  "center"), partial = TRUE, indices = NULL, from = 1L, to = n,
  by = 1L, offsets = NULL, ...)

## S3 method for class 'grouped_df'
roll(data, width = 1L, align = c("left", "right",
  "center"), partial = TRUE, indices = NULL, from = 1L, to = n,
  by = 1L, offsets = NULL, ...)

Arguments

data

A data frame

...

Arguments passed to methods

width

The window width.

align

Is the window left-aligned, right-aligned, or centered relative to the reference index of the window.

partial

logical or numeric. If FALSE all indexes of a rolling window must be within the rows (or groups) of data. If TRUE, then the subset of indexes that are in range are used. A numeric argument to partial can be used to determine the minimal window size for partial windows.

indices, from, to, by

The indices at which to generate windows. If indices is non-NULL, then it is used. Otherwise, the indices are generated from seq(from, to, by).

offsets

An integer vector or NULL. If non-NULL, then it is the offsets of elements in the window relative to the reference index of the window; 0 is the reference index, negative numbers are indices before the index, while positive numbers are after the index. If NULL, the offsets are generated from the width and align arguments.

Value

A data frame with rows equal to the number of windows and the following columns:

train

A list of resample objects. Training sets.

test

A list of resample objects. Test sets.

.id

An integer vector of identifiers

Methods (by class)


jrnold/resamplr documentation built on May 20, 2019, 1:05 a.m.