Skip to content

sec_axis seems to break with tidy evaluation #2788

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

Closed
TylerGrantSmith opened this issue Jul 31, 2018 · 2 comments
Closed

sec_axis seems to break with tidy evaluation #2788

TylerGrantSmith opened this issue Jul 31, 2018 · 2 comments

Comments

@TylerGrantSmith
Copy link

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 sec.axis seems to break with tidy evaluation sec_axis seems to break with tidy evaluation Jul 31, 2018
@dpseidel
Copy link
Collaborator

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.

@lock
Copy link

lock bot commented Feb 2, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Feb 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants