I try to plot a weighted density with ggplot2. The results seem to be fine, but I get the following warning: Warning: Ignoring unknown aesthetics: weight
. Similar problems seem to appear in other ggplot2 applications and therefore I am wondering, if the warning could be ignored.
Reproducible example:
library(ggplot2)
set.seed(123)
# Some random data & weights
x <- rnorm(1000, 5)
w <- x^5
# Plot unweighted
ggplot() + stat_density(aes(x = x))
# Plot weighted - Warning: Ignoring unknown aesthetics: weight
ggplot() + stat_density(aes(x = x, weight = w / sum(w))) # Weighting seems to work fine
# Comparison of weighted density in base graphics - Same results as with ggplot2
plot(density(x, weights = w / sum(w)))
Can this warning message be ignored?