We all love robust measures like medians and interquartile ranges, but lets face it, in many fields, boxplots almost never show up in published articles, while means and sta
This question is almost 2 years old now, but as a new R user in an experimental field, this was a big question for me, and this page is prominent in google results. I just discovered an answer I like better than the current set, so I thought I'd add it.
the package sciplot makes the task super easy. It gets the job done in a single command
#only necessary to get the MPG dataset from ggplot for direct comparison
library(ggplot2)
data(mpg)
attach(mpg)
#the bargraph.CI function with a couple of parameters to match the ggplot example
#see also lineplot.CI in the same package
library(sciplot)
bargraph.CI(
class, #categorical factor for the x-axis
hwy, #numerical DV for the y-axis
year, #grouping factor
legend=T,
x.leg=19,
ylab="Highway MPG",
xlab="Class")
produces this very workable graph with mostly default options. Note that the error bars are standard errors by default, but the parameter takes a function, so they can be anything you want! 