Search code examples
rmachine-learningrecipetidymodels

Tidymodels Recipe Package Use step_normalize On List Of Variables


I want to normalize only an arbitrary selection of variables using step_normalize from the recipe package (tidymodels). Unfortunately I can't find a selection function that seems to work within the step_normalize which selects a list of variables:

library(tidymodels)
iris %>% 
  recipe(Species ~ .) %>% 
  step_normalize(vars_select(Sepal.Length, Petal.Length)) %>% 
  prep()

I get this error message:

Error: Not all functions are allowed in step function selectors (e.g. `vars_select`). See ?selections.

Solution

  • step_normalize does not support this select helper function, this works:

    iris %>% 
      recipe(Species ~ .) %>% 
      step_normalize(Sepal.Length, Petal.Length) %>% 
      prep()
    

    See ?selections for supported selector functions.