1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/selections.R 3\name{has_role} 4\alias{has_role} 5\alias{all_predictors} 6\alias{all_numeric_predictors} 7\alias{all_nominal_predictors} 8\alias{all_outcomes} 9\alias{has_type} 10\alias{all_numeric} 11\alias{all_nominal} 12\alias{current_info} 13\title{Role Selection} 14\usage{ 15has_role(match = "predictor") 16 17all_predictors() 18 19all_numeric_predictors() 20 21all_nominal_predictors() 22 23all_outcomes() 24 25has_type(match = "numeric") 26 27all_numeric() 28 29all_nominal() 30 31current_info() 32} 33\arguments{ 34\item{match}{A single character string for the query. Exact 35matching is used (i.e. regular expressions won't work).} 36} 37\value{ 38Selector functions return an integer vector. 39 40\code{current_info()} returns an environment with objects \code{vars} and \code{data}. 41} 42\description{ 43\code{has_role()}, \code{all_predictors()}, and \code{all_outcomes()} can be used to 44select variables in a formula that have certain roles. 45 46Similarly, \code{has_type()}, \code{all_numeric()}, and \code{all_nominal()} are used to 47select columns based on their data type. Nominal variables include both 48character and factor. 49 50\strong{In most cases}, the selectors \code{all_numeric_predictors()} and 51\code{all_nominal_predictors()}, which select on role and type, will be the right 52approach for users. 53 54See \link{selections} for more details. 55 56\code{current_info()} is an internal function. 57 58All of these functions have have limited utility outside of column selection 59in step functions. 60} 61\examples{ 62library(modeldata) 63data(biomass) 64 65rec <- recipe(biomass) \%>\% 66 update_role( 67 carbon, hydrogen, oxygen, nitrogen, sulfur, 68 new_role = "predictor" 69 ) \%>\% 70 update_role(HHV, new_role = "outcome") \%>\% 71 update_role(sample, new_role = "id variable") \%>\% 72 update_role(dataset, new_role = "splitting indicator") 73 74recipe_info <- summary(rec) 75recipe_info 76 77# Centering on all predictors except carbon 78rec \%>\% 79 step_center(all_predictors(), -carbon) \%>\% 80 prep(training = biomass) \%>\% 81 bake(new_data = NULL) 82 83} 84