ggplot2 : Plot mean with geom_bar

simply use stat = "summary" and fun.y = "mean"

ggplot(test2) + 
  geom_bar(aes(label, X2, fill = as.factor(groups)), 
           position = "dodge", stat = "summary", fun.y = "mean")

enter image description here

Leave a Comment