Learn R Programming

tsibble (version 0.5.3)

slider: Splits the input to a list according to the rolling window size.

Description

Splits the input to a list according to the rolling window size.

Usage

slider(.x, .size = 1, .fill = NA, .partial = FALSE,
  .align = "right", .bind = FALSE)

pslider(..., .size = 1, .fill = NA, .partial = FALSE, .align = "right", .bind = FALSE)

Arguments

.x

An object to slide over.

.size

An integer for window size. If positive, moving forward from left to right; if negative, moving backward (from right to left).

.fill

A value to fill at the left of the data range (NA by default). NULL means no filling.

.partial

if TRUE, split to partial set (FALSE ignores specified .fill and .align).

.align

Align index at the "right", "centre"/"center", or "left" of the window. If .size is even for center alignment, "centre-right" & "centre-left" is needed.

.bind

If .x is a list or data frame, the input will be flattened to a list of data frames.

...

Multiple objects to be split in parallel.

x

An objects to be split.

Examples

Run this code
# NOT RUN {
x <- 1:5
y <- 6:10
z <- 11:15
lst <- list(x = x, y = y, z = z)
df <- as.data.frame(lst)

slider(x, .size = 2)
slider(lst, .size = 2)
pslider(list(x, y), list(y))
slider(df, .size = 2)
pslider(df, df, .size = 2)
# }

Run the code above in your browser using DataLab