-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Suggestion for more informative error message when () missing from geom_* #3571
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
Comments
This has been discussed on #3106 (comment) and some of us actually agreed the error message can be improved. |
I see, thanks for the link! This issue wasn't prompted by confusion between I also agree that this is not widespread confusion, but more of a nice-to-have to help the few who struggle. Note that I have not done a cost-benefit analysis of implementation difficulty vs. benefit of having the improved error in place, so I can't really say if it's "worth it" to make the change. |
Ah, thanks for the context. I guess it won't be very difficult to add some heuristic here, which is called only when raising this error: Lines 90 to 92 in 6f5ffea
|
Yes, just check whether |
Actually, I think this will do it. I can prepare a PR. library(ggplot2)
# ggplot_add variant to be added
ggplot_add.function <- function(object, plot, object_name) {
stop(
"Don't know how to add ", object_name, " to a plot. Did you mean ",
object_name, "()?", call. = FALSE
)
}
# new error message
ggplot() + geom_point
#> Error: Don't know how to add geom_point to a plot. Did you mean geom_point()? Created on 2019-10-28 by the reprex package (v0.3.0) |
See #3594. |
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/ |
If you omit the
()
at the end of a geom, you get the following error:I think the error would be more informative if it continued on to say "Did you mean
geom_boxplot()
?"The text was updated successfully, but these errors were encountered: