-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Mask stage()
at the expression level
#6110
Conversation
Alright as a hail mary, I've changed from wrestling with data masks to changing the calls in the unevaluated aesthetics. # Note: this PR is locally installed for this example
ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy)) +
ggplot2::geom_point(
ggplot2::aes(fill = ggplot2::stage(drv, after_scale = scales::alpha(fill, 0.3))),
shape = 21
) # We cannot use naked `stage()` when we haven't loaded ggplot2
ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy)) +
ggplot2::geom_point(
ggplot2::aes(fill = stage(drv, after_scale = scales::alpha(fill, 0.3))),
shape = 21
)
#> Error in `ggplot2::geom_point()`:
#> ! Problem while computing aesthetics.
#> ℹ Error occurred in the 1st layer.
#> Caused by error in `stage()`:
#> ! could not find function "stage" Created on 2024-09-23 with reprex v2.1.1 |
stage()
at the expression level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I don't suppose there is an elegant way to test this?
The masking mechanic is testable, using |
Well, that is probably sufficient :-) So please add a test for the namespacing |
This PR aims to fix #6104.
It is mutually exclusive with #6108 and #6107.
Briefly, this PR always masks the syntactic functions
after_stat()
,after_scale()
andstage()
.That way, you needn't prefix it with
ggplot2::
if you don't have the namespace attached.And users cannot override these functions, at least when used inside
aes()
.Created on 2024-09-17 with reprex v2.1.1