knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

tidyroll

Lifecycle: experimental Codecov test coverage R build status

tidyroll makes it easy to work with irregular time slices for modeling and prediciton with tidymodels.

The main function rolling_origin_nested() is a wrapper around rsample::rolling_origin and facilitates rolling over different time units instead of a fixed window. The motivation for this function comes from this vignette.

Installation

# install.packages("devtools")
devtools::install_github("gacolitti/tidyroll")

Example

suppressPackageStartupMessages(library(tidyroll))
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(rsample))

data("airquality2")

roll <- rolling_origin_nested(
  data = airquality2, 
  time_var = "date", 
  unit = "month", 
  start = "2017-08-01",
  end = "2017-11-01",
  assess = 1
)
roll

analysis(roll$splits[[1]]) 
assessment(roll$splits[[1]]) 

analysis(roll$splits[[1]])$data %>% last() %>% tail()
assessment(roll$splits[[1]])$data %>% first() %>% head()


gacolitti/tidyroll documentation built on Sept. 13, 2020, 8 p.m.