I want to add total sample size of each facet to geom_histogram
.Expect output as below:
After read this post ,I write script as below:
iris %>%
ggplot(.,mapping=aes(x=Sepal.Length))+
geom_histogram(binwidth= 0.1)+
stat_summary(fun = median, fun.max = length,
geom = "text", aes(label = after_stat(max)), vjust = -1) +
facet_wrap(~Species)
But get error:Error: stat_summary requires the following missing aesthetics: y
.
How to solve this problem?