New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sec_axis seems to break with tidy evaluation #2788

Closed
TylerGrantSmith opened this Issue Jul 31, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@TylerGrantSmith

TylerGrantSmith commented Jul 31, 2018

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

@TylerGrantSmith TylerGrantSmith changed the title from sec.axis seems to break with tidy evaluation to sec_axis seems to break with tidy evaluation Jul 31, 2018

@dpseidel

This comment has been minimized.

Member

dpseidel commented Jul 31, 2018

I've been working on other bugs and features in the secondary axis, so I had a pretty good sense where this was coming from and created a hasty fix this morning with a simple switch in evaluation functions. I need to do due diligence to ensure this isn't breaking anything else, and is an appropriate and general fix but otherwise will write up a PR later this week, hopefully along with some other sec.axis fixes.

dpseidel added a commit that referenced this issue Aug 6, 2018

@josesho josesho referenced this issue Sep 24, 2018

Closed

Release ggplot2 3.1.0 #2890

25 of 25 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment