Skip to content
Prev 310285 / 398526 Next

How to include CI in a grouped barplot?

On Nov 8, 2012, at 7:02 AM, Thais Rangel <thaisrangelnut at gmail.com> wrote:

            
You might take a look at the barplot2() function, which is in the gplots package on CRAN.

Alternatively, read the examples in ?barplot and take note of the example using the VADeaths data set, where it creates faked upper error bars (aka 'dynamite plots', which are shunned heavily). You would need to extend that example, using segments(), to draw the lower bounds and horizontal line segments as well.

The key hint is that barplot() returns the bar midpoints, which then allow you to position vertical lines for each bar center. 

A conceptual note, which is that this format can be ok for proportions/percentages, but you will recommendations against using this format to display continuous data (eg. means +/- SE). In that case, point plots with CI's is preferred. 

Regards,

Marc Schwartz