Learn R Programming

tsibble (version 0.1.0)

tile: Tiling window calculation

Description

tile() is an S3 method to carry out tiling window calculation; tiler() splits the input x to a list according to the window size.

Usage

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

# S3 method for default tile(x, .f, ..., size = 1)

# S3 method for data.frame tile(x, .f, ..., size = 1, deframe = TRUE)

tiler(x, size = 1)

Arguments

x

A vector of numerics, or data frame.

.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.

deframe

TRUE a list is returned. FALSE returns a data frame.

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 ----
sx <- pedestrian %>%
  filter(Sensor == "Southern Cross Station", Date <= as.Date("2015-01-10"))
sx %>% 
  tile(~ quantile(.$Count), size = 48, deframe = FALSE)
# }

Run the code above in your browser using DataLab