recipes_eval_select() is a recipes specific variant of tidyselect::eval_select() enhanced with the ability to recognize recipes selectors, such as all_numeric_predictors(). See selections for more information about the unique recipes selectors.

This is a developer tool that is only useful for creating new recipes steps.

recipes_eval_select(quos, data, info, ..., allow_rename = FALSE)

Arguments

quos

A list of quosures describing the selection. This is generally the ... argument of your step function, captured with ellipse_check() or rlang::enquos() and stored in the step object as the terms element.

data

A data frame to use as the context to evaluate the selection in. This is generally the training data passed to the prep() method of your step.

info

A data frame of term information describing each column's type and role for use with the recipes selectors. This is generally the info data passed to the prep() method of your step.

...

These dots are for future extensions and must be empty.

allow_rename

Should the renaming syntax c(foo = bar) be allowed? This is rarely required, and is currently only used by step_select(). It is unlikely that your step will need renaming capabilities.

Value

A named character vector containing the evaluated selection. The names are always the same as the values, except when allow_rename = TRUE, in which case the names reflect the new names chosen by the user.

Examples

library(rlang)
library(modeldata)
data(scat)

rec <- recipe(Species ~ ., data = scat)

info <- summary(rec)
info
#> # A tibble: 19 × 4
#>    variable  type    role      source  
#>    <chr>     <chr>   <chr>     <chr>   
#>  1 Month     nominal predictor original
#>  2 Year      numeric predictor original
#>  3 Site      nominal predictor original
#>  4 Location  nominal predictor original
#>  5 Age       numeric predictor original
#>  6 Number    numeric predictor original
#>  7 Length    numeric predictor original
#>  8 Diameter  numeric predictor original
#>  9 Taper     numeric predictor original
#> 10 TI        numeric predictor original
#> 11 Mass      numeric predictor original
#> 12 d13C      numeric predictor original
#> 13 d15N      numeric predictor original
#> 14 CN        numeric predictor original
#> 15 ropey     numeric predictor original
#> 16 segmented numeric predictor original
#> 17 flat      numeric predictor original
#> 18 scrape    numeric predictor original
#> 19 Species   nominal outcome   original

quos <- quos(all_numeric_predictors(), where(is.factor))

recipes_eval_select(quos, scat, info)
#>        Year         Age      Number      Length    Diameter       Taper 
#>      "Year"       "Age"    "Number"    "Length"  "Diameter"     "Taper" 
#>          TI        Mass        d13C        d15N          CN       ropey 
#>        "TI"      "Mass"      "d13C"      "d15N"        "CN"     "ropey" 
#>   segmented        flat      scrape     Species       Month        Site 
#> "segmented"      "flat"    "scrape"   "Species"     "Month"      "Site" 
#>    Location 
#>  "Location"