Partially splits the input to a list according to the rolling window size.

partial_slider(.x, .size = 1, .step = 1, .fill = NA,
  .align = "right", .bind = FALSE)

partial_pslider(..., .size = 1, .step = 1, .fill = NA,
  .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).

.step

A positive integer for calculating at every specified step instead of every single step.

.fill

A value to fill at the left/center/right of the data range depending on .align (NA by default). NULL means no filling.

.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, should .x be combined before applying .f? If .x is a list of data frames, row binding is carried out.

...

Additional arguments passed on to the mapped function.

Examples

x <- c(1, NA_integer_, 3:5) slider(x, .size = 3)
#> [[1]] #> [1] 1 NA 3 #> #> [[2]] #> [1] NA 3 4 #> #> [[3]] #> [1] 3 4 5 #>
partial_slider(x, .size = 3)
#> [[1]] #> [1] NA NA 1 #> #> [[2]] #> [1] NA 1 NA #> #> [[3]] #> [1] 1 NA 3 #> #> [[4]] #> [1] NA 3 4 #> #> [[5]] #> [1] 3 4 5 #>