Consider the following lines.
p <- ggplot(mpg, aes(x=factor(cyl), y=..count..))
p + geom_histogram()
p + stat_summary(fun.y=identity, geom='bar')
In theory, the last two should produce the same plot. In practice, stat_summary
fails and complains that the required y aesthetic is missing.
Why can't I use ..count..
in stat_summary
? I can't find anywhere in the docs information about how to use these variables.
stat_bin
which is called bygeom_histogram
, but not bystat_summary
(since you're supposed to be supplying your own stat), hence the variables aren't available. – Armandinaarmando