When recipe steps are used, there are different approaches that can be used to select which variables or features should be used.

The three main characteristics of variables that can be queried:

  • the name of the variable
  • the data type (e.g. numeric or nominal)
  • the role that was declared by the recipe

The manual pages for ?selections and ?has_role have details about the available selection methods.

To illustrate this, the credit data will be used:

Before any steps are used the information on the original variables is:

We can add a step to compute dummy variables on the non-numeric data after we impute any missing data:

This will capture any variables that are either character strings or factors: Status and Records. However, since Status is our outcome, we might want to keep it as a factor so we can subtract that variable out either by name or by role:

Using the last definition:

Status is unaffected.

One important aspect about selecting variables in steps is that the variable names and types may change as steps are being executed. In the above example, Records is a factor variable before the step is executed. Afterwards, Records is gone and the binary variable Records_yes is in its place. One reason to have general selection routines like all_predictors or contains is to be able to select variables that have not be created yet.