我想使用recipe包(tidymodels)中的step_normalize函数,对一组任意选择的变量进行标准化处理。不幸的是,我找不到一个在step_normalize中能够选择变量列表的选择函数:
library(tidymodels)iris %>% recipe(Species ~ .) %>% step_normalize(vars_select(Sepal.Length, Petal.Length)) %>% prep()
我得到了这个错误信息:
Error: Not all functions are allowed in step function selectors (e.g. `vars_select`). See ?selections.
回答:
step_normalize
不支持这个选择辅助函数,以下方法有效:
iris %>% recipe(Species ~ .) %>% step_normalize(Sepal.Length, Petal.Length) %>% prep()
请查看?selections
以了解支持的选择函数。