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 the unquote-splice operator !!!
.
library( ggplot2 )
## Predefine the mapping of symbols to aesthetics
v <- rlang::exprs( x=wt, y=mpg )
## Symbol-by-symbol unquoting works without problems
ggplot( mtcars, aes(!!v$x, !!v$y) ) + geom_point()
## But unquote splicing doesn't...
ggplot( mtcars, aes(!!!v) ) + geom_point()
# Error: Can't use `!!!` at top level
# Call `rlang::last_error()` to see a backtrace
(Perhaps unsurprisingly) The same thing happens if the aesthetic mapping is moved to the geom:
ggplot( mtcars ) + geom_point( aes(!!v$x, !!v$y) ) # works
ggplot( mtcars ) + geom_point( aes(!!!v) ) # doesn't
Am I missing something obvious?