我似乎不知道如何在%$%中使用来自magrittr的tidyeval操作符。下面是这个问题的一个最少可复制的例子:
table与tidyeval之外的公开操作符一起工作
library(magrittr)
print(mtcars %$% table(am))
#> am
#> 0 1
#> 19 13table不适用于tidyeval的公开操作符
foo <- function(data, x) {
# works with pipe operator
print(data %>% dplyr::pull({{ x }}))
# doesn't with exposition operator
data %$% table({{ x }})
}
foo(mtcars, am)
#> [1] 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1
#> Error in table({: object 'am' not found发布于 2021-02-22 09:18:53
dplyr::pull对其参数使用整洁的计算方法。table (作为一个基本的R函数)不起作用,这就是为什么整洁评估适用于前者,而不是后者。这与管道操作员无关。
https://stackoverflow.com/questions/66312808
复制相似问题