The following command generates a simple histogram:
g<- ggplot(data = mtcars, aes(x = factor(carb) )) + geom_histogram()
Usually I add errorbars to my plots like this:
g+stat_summary(fun.data="mean_cl_boot",geom="errorbar",conf.int=.95)
But that doesn't work with a histogram ("Error: geom_errorbar requires the following missing aesthetics: ymin, ymax "), I think because the y variable is not explicit- counts are automatically calculated by geom_histogram, so one doesn't declare the y variable.
Are we unable to use geom_histogram and instead must first calculate the y quantity (counts) ourselves, and then specify it as the y variable with a call to geom_bar?