Closed
Description
While both geom_density()
and stat_density()
compute weighted densities correctly, the later results in an spurious warning (the first of the bunch).
library(ggplot2)
df <- data.frame(x = runif(100))
ggplot(df, aes(x)) +
stat_density(aes(weight = abs(x - 0.5))) +
geom_density(aes(weight = abs(x - 0.5)), color = "red")
#> Warning: Ignoring unknown aesthetics: weight
#> Warning in density.default(x, weights = w, bw = bw, adjust = adjust, kernel
#> = kernel, : sum(weights) != 1 -- will not get true density
#> Warning in density.default(x, weights = w, bw = bw, adjust = adjust, kernel
#> = kernel, : sum(weights) != 1 -- will not get true density
Created on 2018-09-19 by the reprex package (v0.2.0).
(I'm sorry if the multiple similar issues are not cool; you can tell that I'm working with weighted densities in my work and finding these small issues 😆 )