recipes stepstep_expose() creates a specification of a recipe step that will convert
a data frame of census-level records to exposure-level records.
step_expose(
recipe,
...,
role = NA,
trained = FALSE,
end_date,
start_date = as.Date("1900-01-01"),
target_status = NULL,
options = list(cal_expo = FALSE, expo_length = "year"),
drop_pol_num = TRUE,
skip = TRUE,
id = recipes::rand_id("expose")
)An updated version of recipe with the new expose step added to the
sequence of any existing operations. For the tidy method, a tibble with
the columns exposure_type, target_status, start_date, and end_date.
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 selections() for more details.
Not used by this step since no new variables are created.
A logical to indicate if the quantities for preprocessing have been estimated.
Experience study end date
Experience study start date. Default value = 1900-01-01.
Character vector of target status values. Default value
= NULL.
A named list of additional arguments passed to expose().
Whether the pol_num column produced by expose()
should be dropped. Defaults to TRUE.
A logical. Should the step be skipped when the recipe is baked by
bake()? While all operations are baked when prep() is run, some
operations may not be able to be conducted on new data (e.g. processing the
outcome variable(s)). Care should be taken when using skip = TRUE as it
may affect the computations for subsequent operations.
A character string that is unique to this step to identify it.
Policy year exposures are calculated as a default. To switch to calendar
exposures or another exposure length, use pass the appropriate arguments to
the options parameter.
Policy numbers are dropped as a default whenever the recipe is baked. This
is done to prevent unintentional errors when the model formula includes
all variables (y ~ .). If policy numbers are required for any reason
(mixed effect models, identification, etc.), set drop_pol_num to FALSE.
expose()
expo_rec <- recipes::recipe(status ~ ., toy_census) |>
step_expose(end_date = "2022-12-31", target_status = "Surrender",
options = list(expo_length = "month")) |>
prep()
recipes::juice(expo_rec)
Run the code above in your browser using DataLab