我正在尝试创建一个直方图,其中 bin 高度是落入每个 bin 的值的平均值。下面 p2 的代码是我认为可行的。
library(ggplot2)
m <- mtcars[1:20, ];
p <- ggplot(m, aes(x = mpg)) + geom_histogram(binwidth = 5);
p <- p + aes(weight = wt); # works, but is the sum of the wt
p2 <- p + aes(weight = wt / ..count..); # does not work, but the idea I am going for
抱歉,如果我在这里遗漏了一些明显的东西,但我感谢您的帮助。