Closed
Description
I am trying to add a transformed secondary axis in a function which is using quasiquotations, but sec_axis
errors saying that it can't find one of the quoted variables. This only happens when changing trans
from its default ~.
. For example, dup_axis
works fine. reprex included below.
library(tidyverse)
#> -- Attaching packages ------------------------------- tidyverse 1.2.1 --
#> v ggplot2 3.0.0 v purrr 0.2.4
#> v tibble 1.4.2 v dplyr 0.7.6
#> v tidyr 0.8.1 v stringr 1.3.1
#> v readr 1.1.1 v forcats 0.2.0
#> -- Conflicts ---------------------------------- tidyverse_conflicts() --
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag() masks stats::lag()
f <- function(df, .x, .y, .z) {
x<-enquo(.x)
y<-enquo(.y)
z<-enquo(.z)
g <- ggplot(df,aes(x=!!x,y=!!y)) +
geom_bar(stat="identity") +
geom_point(aes(y=!!z)) +
scale_y_continuous(sec.axis = sec_axis(~./10))
g
}
t <- tibble(x = letters, y = seq(10,260, 10), z = 1:26)
f(t, x, y, z)
#> Error in as.list.environment(x, all.names = TRUE): object 'x' not found
Metadata
Metadata
Assignees
Labels
No labels