【发布时间】:2020-10-15 08:16:53
【问题描述】:
我需要使用来自 tidymodels 的食谱包创建一个食谱。在其中一个步骤中,我需要将有序因子转换为它们的序数分数。但似乎没有我可以的功能 用于选择所有有序因子。
我知道有一个名为all_nominal() 的函数,但它匹配作为因子的每一列,它可以是有序的或无序的。我也尝试过has_type("ordered"),但这也不起作用。
目前,我必须手动输入列名。有没有更简单的方法来做到这一点?
下面是我想做的一个例子:
library(mlbench)
data("BreastCancer")
rec <- recipe(Class ~ ., BreastCancer) %>%
# Here, I want to select all ordered nominals instead of
# listing them by name. Should there be a function
# all_ordinal in recipes? Or is there another way
# to accomplish this?
step_ordinalscore(Cl.thickness,
Cell.size,
Cell.shape,
Marg.adhesion,
Epith.c.size)
欢迎任何帮助,谢谢。
【问题讨论】:
标签: r tidymodels r-recipes