Learn R Programming

tsibble (version 0.2.0)

tile: Tiling window calculation

Description

Tiling window without overlapping observations:

  • tile() always returns a vector of numerics

  • tile_lst() returns a list

  • tile_dfr() return data frame using row-binding

  • tiler() splits the input x to a list according to the window size.

Usage

tile(x, .f, ..., size = 1)

tile_lst(x, .f, ..., size = 1)

tile_dfr(x, .f, ..., size = 1, .id = NULL)

tiler(x, size = 1)

Arguments

x

A vector of numerics, or data frame. If a data frame, row-wise rolling window is performed.

.f

A function or one-sided formula using purrr-like syntax. If a formula, it is converted to a function.

...

Additional arguments passed on to .f.

size

An integer for window size.

.id

If not NULL a variable with this name will be created giving either the name or the index of the data frame, which is passed to dplyr::bind_rows.

See Also

slide for sliding window with overlapping observations; stretch for expanding more observations

Examples

Run this code
# NOT RUN {
# tiling over a vector ----
x <- 1:10
tile(x, sum, size = 3)
tile(x, ~ sum(.), size = 3)
tiler(x, size = 3)

# tiling over a 2-day window for hourly data ----
# }
# NOT RUN {
pedestrian %>% 
  split_by(Sensor) %>% 
  purrr::map_dfr(~ tile_dfr(., ~ quantile(.$Count), size = 48))
# }

Run the code above in your browser using DataLab