what is geom="errorbar" ?

Hi, sorry my question is more theoretical.
I'm not clear on what the whiskers in the following represents: is it the standard deviation or the min/max values (except for the outliers)? Thanks

boxp <- ggplot(mtcars, aes(as.factor(cyl), wt, group = interaction(as.factor(cyl), as.factor(am)))) +
  geom_bar(aes(fill=as.factor(am)), position = "dodge", stat = "summary", fun = "median") +
  geom_boxplot(outlier.shape = NA, width=0.2, color = "black", fill = 'gray', position = position_dodge(0.9)) +
  stat_boxplot(geom="errorbar", position = position_dodge(0.9)) +
  stat_summary(aes(label=round(after_stat(y), 2), y = stage(wt, after_stat = 0)), fun=median, geom="text", size=8, col = "white", vjust=-0.5,position = position_dodge(0.9)) +
  stat_summary(fun=mean, geom="point", shape=18, size=4, col="white", position = position_dodge(0.9)) +
  labs(x = "Conditions", y = "Medians") +
  scale_y_continuous(limits=c(0,7),oob = rescale_none) +
  theme_bw()
boxp

https://stackoverflow.com/questions/45887705/what-does-geom-errorbar-mean-which-algorithm-is-it

does this answer your question?

so so. I mean that question is, as mine, about stat_boxplot(geom="errorbar")
but the reply is about geom_errorbar..are these the same thing?

Specifying the geom in stat_boxplot() or the stat in geom_boxplot() can be used to "to override the default connection between geom_boxplot and stat_boxplot."


For example, if you provided the layer with different data or mapped its aesthetics to a different variable, or if you wanted to manually provide the limits to the geometry shown, etc.

From the ggplot2 function reference page:

A layer combines data, aesthetic mapping, a geom (geometric object), a stat (statistical transformation), and a position adjustment. Typically, you will create layers using a geom_ function, overriding the default position and stat if needed.

2 Likes

now I understand..I was confused. Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.