I can't seem to figure out how to use the %$%
operator from magrittr
with tidyeval
. Here is a minimally reproducible example of this problem:
table
works with exposition operator outside tidyeval
library(magrittr)
print(mtcars %$% table(am))
#> am
#> 0 1
#> 19 13
table
doesn't work with exposition operator with 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
dplyr::pull
uses tidy evaluation for its arguments. table
(being a base R function) doesn’t. That’s why tidy evaluation works with the former but not the latter. This is unrelated to the pipe operator.