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.
Getting ready
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= ...
Get R: Data Analysis and Visualization now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.