Skip to content

Improved stat_function() documentation #3362 #3415

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

Merged
merged 8 commits into from
Jul 9, 2019

Conversation

thiyangt
Copy link
Contributor

@thiyangt thiyangt commented Jul 8, 2019

Closes #3362

@lionel- lionel- added the tidy-dev-day 🤓 Tidyverse Developer Day label Jul 8, 2019
Copy link
Member

@lionel- lionel- left a comment

Choose a reason for hiding this comment

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

Could you redocument with devtools::document() (or from the Build menu in RStudio) please? This will regenerate the .Rd files which contain the documentation. The Rd changes should be part of the commit.

@lionel-
Copy link
Member

lionel- commented Jul 8, 2019

Would you like to also add a warning when mapping or data is supplied, as suggested in #3362 (comment)?

@lionel-
Copy link
Member

lionel- commented Jul 8, 2019

Thanks! The warnings will also need unit tests that you can add in tests/testthat/test-stats-function.r. This should look like:

expect_warning(stat_function(aes(), fun = identity), "Ignoring `mapping`")

However I see the warning currently is:

warn_overwritten_args("stat_function()", "mapping", "group")
#> Warning message:
#> stat_function(): Ignoring `mapping` because `group` was provided.

Which doesn't look right. It's probably better to just call warning() directly with custom messages. Any suggestion as to how best formulate the two warnings @paleolimbot? I'm not sure I entirely understand its semantics.

@paleolimbot
Copy link
Member

You're right @lionel- ...I think it would be more accurate here to write

   warning("`mapping` is not used by stat_function()", call. = FALSE)

@lionel- lionel- merged commit 125cc5f into tidyverse:master Jul 9, 2019
@lionel-
Copy link
Member

lionel- commented Jul 9, 2019

The PR just needed another small change, the warnings needed to be above the layer() call, otherwise the stat_function() would not return anything. No big deal, I have pushed a quick fix: 6ba9275.

Thanks for these improvements to ggplot2!

@lock
Copy link

lock bot commented Jan 5, 2020

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 Jan 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tidy-dev-day 🤓 Tidyverse Developer Day
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Layer data mapping are ignored in stat_function()
3 participants