Skip to content

Silence additional weight warnings #5267

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

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5263.

It continuous the saga of silencing dropped weight warnings, like #5071 and #5218 before it.

I also found geom_dotplot() to use a weight aesthetic, but it reports it doesn't and throws a warning about dropped weights when present. I fixed this by promoting it to a visible aesthetic and silencing the warning. In the example below, only the bin width warnings persist.

library(ggplot2)

p <- ggplot(mtcars, aes(x = mpg))
p1 <- p + geom_dotplot(aes(weight = cyl))
#> Warning in geom_dotplot(aes(weight = cyl)): Ignoring unknown aesthetics: weight
p2 <- p + geom_dotplot()
patchwork::wrap_plots(p1, p2)
#> Bin width defaults to 1/30 of the range of the data. Pick better value with
#> `binwidth`.
#> Warning: The following aesthetics were dropped during statistical transformation: weight
#> ℹ This can happen when ggplot fails to infer the correct grouping structure in
#>   the data.
#> ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
#>   variable into a factor?
#> Bin width defaults to 1/30 of the range of the data. Pick better value with
#> `binwidth`.

Created on 2023-04-12 with reprex v2.0.2

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

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

LGTM

@teunbrand teunbrand merged commit e4fc12d into tidyverse:main Apr 15, 2023
@teunbrand teunbrand deleted the weight_warning_2_electric_boogaloo branch April 15, 2023 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

geom_violin() warns that weight aesthetic dropped during statistical transformation
2 participants