Tidyeval splice operator !!! fails with ggplot's aes

后端 未结 1 1168
被撕碎了的回忆
被撕碎了的回忆 2021-01-22 17:27

The article discussing tidy evaluation in ggplot2 gives the impression that aes() now supports quasiquoation. However, I\'m having problems getting it to work with

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-22 17:45

    That's because aes() takes x and y arguments and !!! only works within dots. We'll try to solve this particular problem in the future. In the interim you'll need to unquote x and y individually, or use the following workaround:

    aes2 <- function(...) {
      eval(expr(aes(!!!enquos(...))))
    }
    
    ggplot(mtcars, aes2(!!!v)) + geom_point()
    

    0 讨论(0)
提交回复
热议问题