遵循以下文档?across
:
across(.cols = everything(), .fns = NULL, ..., .names = NULL)
我用作everything()
LHS 的参考。
然而,似乎也everything()
没有从管道接收 LHS 对象。.
我错过了什么?
重复:
library(dplyr)
# this works as expected
iris %>%
select(Sepal.Length:Petal.Width) %>%
mutate_all(as.character) %>% glimpse
Rows: 150
Columns: 2
$ Sepal.Length <chr> "5.1", "4.9", "4.7", "4.6", "5", "5.4", "4.6", "5…
$ Sepal.Width <chr> "3.5", "3", "3.2", "3.1", "3.6", "3.9", "3.4", "3…
# this doesn't work
iris %>%
select(Sepal.Length:Sepal.Width) %>%
mutate(across(.cols = everything(), .fns = as.character)) %>% glimpse
Rows: 150
Columns: 2
$ Sepal.Length <dbl> 5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.9,…
$ Sepal.Width <dbl> 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1,…