-
Notifications
You must be signed in to change notification settings - Fork 2.1k
geom_bin_2d: warning message when using weight without group #5216
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
Thanks for the report! Is this conceptually similar to #5053, where also an inappropriate warning was emitted? |
Yes, I believe it is the same. Sorry I didn't see that when searching for issues before writing this one. |
This comment was marked as outdated.
This comment was marked as outdated.
Reviewing when this occurs, I found that many more stats mention dropping weights. I think the weights are being dropped by design, so we don't need these warnings. library(ggplot2)
ggplot(data.frame(x = 1:2)) +
aes(x, y = x, weight = x) +
geom_bin_2d()
#> 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? ggplot(data.frame(x = c("A", "A", "B", "B"), y = 1:4)) +
aes(x, y, weight = seq_along(y)) +
geom_boxplot()
#> 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? ggplot(faithfuld, aes(waiting, eruptions, z = density)) +
geom_contour(aes(weight = seq_along(density)))
#> 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? ggplot(data.frame(x = 1:2)) +
aes(x, y = x, weight = x) +
geom_hex()
#> 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? ggplot(data.frame(x = 1:2)) +
aes(x, x, weight = x) +
stat_quantile()
#> Smoothing formula not specified. Using: y ~ x
#> 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? Created on 2023-03-06 with reprex v2.0.2 |
I found a problem with geom_bin_2d
I expected to be able to use a weight variable without a group variable but get a warning when I do this. The weight does seem to be used appropriately as the result is different when not using the weight.
Here is the code to reproduce the bug:
Created on 2023-03-05 with reprex v2.0.2
Standard output and standard error
Session info
The text was updated successfully, but these errors were encountered: