Skip to content

Better error message when trying to add a function to a plot. - #3594

Merged
clauswilke merged 2 commits into
tidyverse:masterfrom
wilkelab:issue-3571-ggplot_add
Oct 29, 2019
Merged

clauswilke merged 2 commits into
tidyverse:masterfrom
wilkelab:issue-3571-ggplot_add

Conversation

@clauswilke

Copy link
Copy Markdown
Member

This closes #3571:

library(ggplot2)
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)

@yutannihilation yutannihilation left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Comment thread R/plot-construction.r
Comment on lines +103 to +107
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
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use abort()? Or will it be done in #3526?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

Comment thread NAMESPACE Resolved
@clauswilke
clauswilke merged commit 5188f5e into tidyverse:master Oct 29, 2019
@clauswilke
clauswilke deleted the issue-3571-ggplot_add branch October 29, 2019 16:32
@lock

lock Bot commented May 5, 2020

Copy link
Copy Markdown

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 May 5, 2020
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 this pull request may close these issues.

Suggestion for more informative error message when () missing from geom_*

2 participants