-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Duplicated aes warning with multiple modified aesthetics #4707
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
Changes from 6 commits
59850ac
86787de
fb872e8
f0af65b
e954f6c
6c27fed
de58b45
0143602
b1347dc
6589d99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# staged aesthetics warn appropriately for duplicated names | ||
|
||
Duplicated aesthetics after name standardisation: colour | ||
|
||
--- | ||
|
||
Duplicated aesthetics after name standardisation: colour | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,19 @@ test_that("make_labels() deprases mappings properly", { | |
expect_identical(make_labels(aes(x = 1)), list(x = "x")) | ||
expect_identical(make_labels(aes(x = NULL)), list(x = "x")) | ||
}) | ||
|
||
test_that("staged aesthetics warn appropriately for duplicated names", { | ||
# Test should *not* report `NA` as the duplicated aes (#4707) | ||
df <- data.frame(x = 1, y = 1, lab = "test") | ||
expr <- substitute( | ||
ggplot(df, aes(x, y, label = lab)) + | ||
geom_label( | ||
aes(colour = stage(lab, after_scale = colour), | ||
color = after_scale(color)) | ||
) | ||
) | ||
# One warning in plot code due to evaluation of `aes()` | ||
expect_snapshot_warning(p <- eval(expr)) | ||
# Two warnings in building due to `stage()`/`after_scale()` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I only see one warning in the test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah indeed! The second of those warnings only occurred when |
||
expect_snapshot_warning(ggplot_build(p)) | ||
}) |
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.
Since I don't think you're actually doing any substitution,
quote()
would be more appropriate here. But I think you could also just dop <- ggplot() + ...
in theexpect_snapshot_warning()
.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.
Good points, I wasn't aware of this, so thanks!