step_time_event | R Documentation |
step_time_event()
creates a specification of a recipe step that will
create new columns indicating if the date fall on recurrent event.
step_time_event(
recipe,
...,
role = "predictor",
trained = FALSE,
rules = list(),
columns = NULL,
keep_original_cols = FALSE,
skip = FALSE,
id = rand_id("time_event")
)
recipe |
A recipe object. The step will be added to the sequence of operations for this recipe. |
... |
One or more selector functions to choose variables
for this step. See |
role |
Not used by this step since no new variables are created. |
trained |
A logical to indicate if the quantities for preprocessing have been estimated. |
rules |
Named list of |
columns |
A character string of variables that will be
used as inputs. This field is a placeholder and will be
populated once |
keep_original_cols |
A logical to keep the original variables in the
output. Defaults to |
skip |
A logical. Should the step be skipped when the
recipe is baked by |
id |
A character string that is unique to this step to identify it. |
Unlike some other steps step_time_event
does not remove the
original date variables by default. Set keep_original_cols
to FALSE
to
remove them.
An updated version of recipe
with the new check added to the
sequence of any existing operations.
library(recipes)
library(extrasteps)
library(almanac)
library(modeldata)
data(Chicago)
on_easter <- yearly() %>% recur_on_easter()
on_weekend <- weekly() %>% recur_on_weekends()
rules <- list(easter = on_easter, weekend = on_weekend)
rec_spec <- recipe(ridership ~ date, data = Chicago) %>%
step_time_event(date, rules = rules)
rec_spec_preped <- prep(rec_spec)
bake(rec_spec_preped, new_data = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.