-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Clearer error messages for invalid aesthetics #3091
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 2 commits
99b4d05
078f650
33c953d
aed6a9b
1ed5714
329d2c9
6dbca4c
81e45ea
5aacacb
c2cc4d0
a789ac3
a7a70ae
eb796a3
4f09ced
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 |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
|
||
* `coord_map()` now can have axes on the top and right (@karawoo, #3042). | ||
|
||
* Clearer error messages for innappropriate aesthetics. (@clairemcwhite, #3060). | ||
|
||
* `geom_rug()` gains an "outside" option to allow for moving the rug tassels to outside the plot area. (@njtierney, #3085) | ||
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. Do we have an idea of where this news item comes from? It should have been present in NEWS.md already, but it isn't, so I'm confused about both why it was lost and how it made its reappearance here. 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, it was moved in this commit: 230e8f7 so you can just delete it here. 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. Got it, will do in next commit. |
||
|
||
* `geom_rug()` now works with `coord_flip()` (@has2k1, #2987). | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -229,6 +229,15 @@ Layer <- ggproto("Layer", NULL, | |
evaled <- lapply(aesthetics, rlang::eval_tidy, data = data) | ||
evaled <- compact(evaled) | ||
|
||
nondata_cols <- check_nondata_cols(evaled) | ||
if(length(nondata_cols) > 0){ | ||
msg <- paste0( | ||
"Aesthetics must be valid data columns: ", nondata_cols, | ||
". Did you forget to add stat()?" | ||
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. Is forgetting 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. There's two ways to get to this point: Forgetting 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. Can we display the thing that they actually typed? Then we could hint to check that 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 don't know how to get it to print the actual typed statement, but now it prints the problematic aesthetic (along with the tilde). Situation 1: Error: Aesthetics must be valid computed stats: Situation 2:
Don't know how to automatically pick scale for object of type function. Defaulting to continuous. |
||
) | ||
stop(msg, call. = FALSE) | ||
} | ||
clairemcwhite marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
n <- nrow(data) | ||
if (n == 0) { | ||
# No data, so look at longest evaluated aesthetic | ||
|
@@ -280,6 +289,17 @@ Layer <- ggproto("Layer", NULL, | |
env$stat <- stat | ||
|
||
stat_data <- new_data_frame(lapply(new, rlang::eval_tidy, data, env)) | ||
|
||
# Check that all columns in aesthetic stats are valid data | ||
nondata_stat_cols <- check_nondata_cols(stat_data) | ||
if(length(nondata_stat_cols) > 0){ | ||
clairemcwhite marked this conversation as resolved.
Show resolved
Hide resolved
|
||
msg <- paste0( | ||
"Aesthetics must be valid computed stats: ", nondata_stat_cols, | ||
". Did you map your stat in the wrong layer?" | ||
) | ||
stop(msg, call. = FALSE) | ||
} | ||
|
||
names(stat_data) <- names(new) | ||
|
||
# Add any new scales, if needed | ||
|
Uh oh!
There was an error while loading. Please reload this page.