Skip to content
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

Cryptic errors because Geom*$setup_data runs before check_required_aes #2637

Closed
brodieG opened this issue May 19, 2018 · 1 comment · Fixed by #2754
Closed

Cryptic errors because Geom*$setup_data runs before check_required_aes #2637

brodieG opened this issue May 19, 2018 · 1 comment · Fixed by #2754

Comments

@brodieG
Copy link
Contributor

brodieG commented May 19, 2018

Failure to check aesthetics for geoms that use setup_data can cause cryptic error messages:

ggplot(iris) + geom_col()
## Error in pmin(y, 0) : object 'y' not found
## In addition: Warning messages:
## 1: In min(x, na.rm = na.rm) :
##  no non-missing arguments to min; returning Inf
## 2: In max(x, na.rm = na.rm) :
##   no non-missing arguments to max; returning -Inf
## 3: In min(diff(sort(x))) : no non-missing arguments to min; returning Inf

Compare to:

ggplot(iris) + geom_point()
## Error: geom_point requires the following missing aesthetics: x, y

This is because in Layer$compute_geom_1 we setup_data before we check_required_aesthetics.

I can definitely see the rationale for this if it is the case that some required aesthetics are generated by setup_data, which I guess is possible but seems a bit odd. After all, why would we require an aesthetic that would be auto generated?

The change is in theory trivial, but I can imagine it is possible there would be unintended consequences. I can make the change, test to see if anything breaks, and so on, but probably not in the next couple of weeks. If you're interested let me know and I'll work on a PR for the next release.

@lock
Copy link

lock bot commented Feb 3, 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 3, 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

Successfully merging a pull request may close this issue.

1 participant