library(recipes)
library(dplyr)
# Sample Data
dates_in_2017_tbl <- tibble::tibble(
index = tk_make_timeseries("2017-01-01", "2017-12-31", by = "day")
)
# Add US holidays and Non-Working Days due to Holidays
# - Physical Holidays are added with holiday pattern (individual) and locale_set
rec_holiday <- recipe(~ ., dates_in_2017_tbl) %>%
step_holiday_signature(index,
holiday_pattern = "^US_",
locale_set = "US",
exchange_set = "NYSE")
# Not yet prep'ed - just returns parameters selected
rec_holiday %>% tidy(1)
# Prep the recipe
rec_holiday_prep <- prep(rec_holiday)
# Now prep'ed - returns new features that will be created
rec_holiday_prep %>% tidy(1)
# Apply the recipe to add new holiday features!
bake(rec_holiday_prep, dates_in_2017_tbl)
Run the code above in your browser using DataLab