has_role {recipes} | R Documentation |
has_role
, all_predictors
, and all_outcomes
can be used
to select variables in a formula that have certain roles. Similarly,
has_type
, all_numeric
, and all_nominal
are used to
select columns based on their data type. See selections
for
more details. current_info
is an internal function that is
unlikely to help users while the others have limited utility outside of
step function arguments.
has_role(match = "predictor", roles = current_info()$roles) all_predictors(roles = current_info()$roles) all_outcomes(roles = current_info()$roles) has_type(match = "numeric", types = current_info()$types) all_numeric(types = current_info()$types) all_nominal(types = current_info()$types) current_info()
match |
A single character string for the query. Exact matching is used (i.e. regular expressions won't work). |
roles |
A character string of roles for the current set of terms. |
types |
A character string of roles for the current set of data types |
Selector functions return an integer vector while
current_info
returns an environment with vectors vars
,
roles
, and types
.
data(biomass) rec <- recipe(biomass) %>% add_role(carbon, hydrogen, oxygen, nitrogen, sulfur, new_role = "predictor") %>% add_role(HHV, new_role = "outcome") %>% add_role(sample, new_role = "id variable") %>% add_role(dataset, new_role = "splitting indicator") recipe_info <- summary(rec) recipe_info has_role("id variable", roles = recipe_info$role) all_outcomes(roles = recipe_info$role)