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
stat_count gives cryptic error when used on a column of doubles #4609
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Minimal reprex: library(ggplot2)
df <- data.frame(x = rep(c(1, 2), 5) + rep(c(0, -2.220446e-16), c(4, 1)))
df
#> x
#> 1 1
#> 2 2
#> 3 1
#> 4 2
#> 5 1
#> 6 2
#> 7 1
#> 8 2
#> 9 1
#> 10 2
ggplot(df, aes(x)) + geom_bar()
#> Warning: Computation failed in `stat_count()`:
#> Elements must equal the number of rows or 1 Created on 2022-03-15 by the reprex package (v2.0.1) Since this seems like a FP buglet I think it's worth taking a bit of a look to see what's going wrong. |
It seems the problem is that the criteria of the "same" value differ between Lines 79 to 89 in a979ffd
df <- data.frame(x = rep(c(1, 2), 5) + rep(c(0, -2.220446e-16), c(4, 1)))
ggplot2:::unique0(df$x)
#> [1] 1 2 1 2
tapply(rep(1, times = nrow(df)), df$x, sum, na.rm = TRUE)
#> 1 2
#> 5 5
as.factor(df$x)
#> [1] 1 2 1 2 1 2 1 2 1 2
#> Levels: 1 2 Created on 2022-07-23 by the reprex package (v2.0.1) |
In such case, should we add a tolerance or treat them as unequal? If treated as unequal, we could replace the |
I'd say we follow whatever |
Run this trivial code (csv is attached):
You get this warning:
This is the resulting plot:
The data:
data.csv
Expected behavior: it should "just work". All the data in this tibble is just doubles. I reviewed the
geom_bar
documentation, and I see no contraindications for this working.If I have done something wrong here, then this becomes a feature request for a useful error message or improved documentation.
The text was updated successfully, but these errors were encountered: