Learn R Programming

tsibble (version 0.6.2)

future_slide: Sliding window in parallel

Description

Multiprocessing equivalents of slide(), tile(), stretch() prefixed by future_.

  • Variants for corresponding types: future_*_lgl(), future_*_int(), future_*_dbl(), future_*_chr(), future_*_dfr(), future_*_dfc().

  • Extra arguments .progress and .options for enabling progress bar and the future specific options to use with the workers.

Arguments

Details

It requires the package furrr to be installed. Please refer to furrr for performance and detailed usage.

Examples

Run this code
# NOT RUN {
if (!requireNamespace("furrr", quietly = TRUE)) {
  stop("Please install the furrr package to run these following examples.")
}
# }
# NOT RUN {
library(furrr)
plan(multiprocess)
my_diag <- function(...) {
  data <- list(...)
  fit <- lm(Count ~ Time, data = data)
  tibble(fitted = fitted(fit), resid = residuals(fit))
}
pedestrian %>%
  nest(-Sensor) %>%
  mutate(diag = future_map(data, ~ future_pslide_dfr(., my_diag, .size = 48)))
# }

Run the code above in your browser using DataLab