Creating a bar chart with error bars
A bar chart with error bars is another commonly used data visualization technique. In this recipe, we will produce a bar chart with error bars.
To produce a bar chart with error bars, we need to process the dataset in such a way that we have the relevant data at hand. In fact, to produce the error bar, we need to have the standard error of the mean that can be transformed into the lower and upper limit. To make this happen, we will call
ggplotdata first, and then will do some processing using the following code:
# Summarizing the dataset to calculate mean # calculating margin of error for 95% confidence interval of mean bardata <- ddply(ggplotdata,.(econ_status),summarize,n=length(disA),meandisA=mean(disA),sdA=sd(disA),errMargin= ...