这个问题是为了加深对 R 函数 Across & Which 的理解。我运行了这段代码并得到了消息。我想了解
a) 好的和坏的做法有什么区别
b) where 函数在一般情况下和在这个用例中是如何工作的
library(tidyverse)
iris %>% mutate(across(is.character,as.factor)) %>% str()
Warning message:
Problem with `mutate()` input `..1`.
i Predicate functions must be wrapped in `where()`.
# Bad
data %>% select(is.character)
# Good
data %>% select(where(is.character))
i Please update your code.