-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add evaluating environment to tidy eval call. Closes #2835 #2836
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
Conversation
Can you add a unit test please? This would be a good start: n <- 100
p <- ggplot() + scale_y_continuous(sec_axis(trans = ~ . / n))
expect_error(regexp = NA, ggplot_build(p)) No need to wrap in Edit: Or would it be good practice to wrap in |
@hadley I think we should provide a way of supporting quasiquotation for this type of transformation. There's a bug in @IndrajeetPatil's function: whenever the data frame contains a column We could support quosures: sec_axis(trans = quo(. / !!total_obs)) But that feels like a strange UI. It might be better to provide a formula constructor in rlang: sec_axis(trans = f(. / !!total_obs)) Which could also be useful for statistical models. |
@lionel- Thanks, I will add the test case you suggest and also think about making one that tests scaling. Does the proposed fix to the bug look correct to you? |
Yup, but if we'd like to support quosures it'll need a slightly different approach. If we go for a formula constructor with qq support then there's no further change needed. |
Looks good! |
Yep! Your modification shouldn't change the original intent, looks good to me. |
Great, thanks! If somebody can approve I'll merge. |
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/ |
This PR adds the calling environment to the transformation evaluation in the secondary axis. This closes #2835.