recipes_argument_select: Evaluate a selection with tidyselect semantics for arguments

View source: R/misc.R

recipes_argument_selectR Documentation

Evaluate a selection with tidyselect semantics for arguments

Description

recipes_argument_select() is a variant of recipes_eval_select() that is tailored to work well with arguments in steps that specify variables. Such as denom in step_ratio().

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

Usage

recipes_argument_select(
  quos,
  data,
  info,
  single = TRUE,
  arg_name = "outcome",
  call = caller_env()
)

Arguments

quos

A list of quosures describing the selection. Captured with rlang::enquos() and stored in the step object corresponding to the argument.

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.

single

A logical. Should an error be thrown if more than 1 variable is selected. Defaults to TRUE.

arg_name

A string. Name of argument, used to enrich error messages.

call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of rlang::abort() for more information.

Details

This function is written to be backwards compatible with previous input types of these arguments. Will thus accept strings, tidyselect, recipes selections, helper functions imp_vars() in addition to the prefered bare names.

Value

A character vector containing the evaluated selection.

See Also

developer_functions

Examples


library(rlang)
data(scat, package = "modeldata")

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

info <- summary(rec)
info

recipes_argument_select(quos(Year), scat, info)
recipes_argument_select(vars(Year), scat, info)
recipes_argument_select(imp_vars(Year), scat, info)


tidymodels/recipes documentation built on April 17, 2025, 6:17 p.m.