add_role {recipes} | R Documentation |
add_role
can add a role definition to an existing variable in the
recipe.
add_role(recipe, ..., new_role = "predictor")
recipe |
An existing |
... |
One or more selector functions to choose which variables are
being assigned a role. See |
new_role |
A character string for a single role. |
If a variable is selected that currently has a role, the role is changed and a warning is issued.
An updated recipe object.
data(biomass) # Create the recipe manually rec <- recipe(x = biomass) rec summary(rec) rec <- rec %>% add_role(carbon, contains("gen"), sulfur, new_role = "predictor") %>% add_role(sample, new_role = "id variable") %>% add_role(dataset, new_role = "splitting variable") %>% add_role(HHV, new_role = "outcome") rec