# NOT RUN {
set.seed(1131)
ex_data <- data.frame(row = 1:20, some_var = rnorm(20))
dim(rolling_origin(ex_data))
dim(rolling_origin(ex_data, skip = 2))
dim(rolling_origin(ex_data, skip = 2, cumulative = FALSE))
# You can also roll over calendar periods by first nesting by that period,
# which is especially useful for irregular series where a fixed window
# is not useful. This example slides over 5 years at a time.
library(dplyr)
data(drinks)
drinks_annual <- drinks %>%
mutate(year = as.POSIXlt(date)$year + 1900) %>%
nest(-year)
multi_year_roll <- rolling_origin(drinks_annual, cumulative = FALSE)
analysis(multi_year_roll$splits[[1]])
assessment(multi_year_roll$splits[[1]])
# }
Run the code above in your browser using DataLab