suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(recipes))
len_out <- 10
by_unit <- "month"
start_date <- as.Date("2021-01-01")
data_tbl <- tibble(
date_col = seq.Date(from = start_date, length.out = len_out, by = by_unit),
a = rnorm(len_out),
b = runif(len_out)
)
# Create a recipe object
rec_obj <- recipe(a ~ ., data = data_tbl) %>%
step_hai_fourier_discrete(b, scale_type = "sin") %>%
step_hai_fourier_discrete(b, scale_type = "cos") %>%
step_hai_fourier_discrete(b, scale_type = "sincos")
# View the recipe object
rec_obj
# Prepare the recipe object
prep(rec_obj)
# Bake the recipe object - Adds the Time Series Signature
bake(prep(rec_obj), data_tbl)
rec_obj %>% get_juiced_data()
Run the code above in your browser using DataLab