# Clustered Error Bar for Groups of Cases.

# Example: Experimental Condition (Stereotype Threat Yes/No) x Gender (Male / Female)

# The following values would be calculated from data and are set fixed now for

# code reproduction























names(stderr.males)



# Error Bar Plot



library (gplots)



# Draw the error bar for female experiment participants:

plotCI(x = means.females, uiw = stderr.females, lty = 2, xaxt ="n", xlim = c(0.5,2.5), ylim = c(-1,1), gap = 0, ylab="Microworld Performance (Z Score)", xlab="Stereotype Threat", main = "Microworld performance over experimental conditions")



# Add the males to the existing plot

plotCI(x = means.males, uiw = stderr.males, lty = 1, xaxt ="n", xlim = c(0.5,2.5), ylim = c(-1,1), gap = 0, add = TRUE)



# Draw the x-axis (omitted above)

axis(side = 1, at = 1:2, labels = names(stderr.males), cex = 0.7)



# Add legend for male and female participants

legend(2,1,legend=c("Male","Female"),lty=1:2)



[1] Cumming, G., & Finch, S. (2005). Inference by Eye: Confidence Intervals and How to Read Pictures of Data. American Psychologist, 60(2), 170–180. names(means.males)[1] Cumming, G., & Finch, S. (2005). Inference by Eye: Confidence Intervals and How to Read Pictures of Data. American Psychologist, 60(2), 170–180. Labels: R, spss, statistics stderr.males means.males names(stderr.females) names(means.females) stderr.females means.females

One of the reasons why I haven't made the switch from R to SPSS is R's lack of proper error bar graphs. I use them frequently because they are easy to interpret: If you plot the means of several groups of participants in one error bar chart and scale the error bars to a length of one standard measurement error, non-overlapping error bars indicate a significant difference between the according means. In fact, the APA advocates the use of error bars for reporting results since 2005 [1]. This way of reporting differences in means is also called "Inference by Eye" [1].After my rants about SPSS, my wise R mentor, Stephan Kolassa, pointed me at the gplots library that features a good function for drawing error bars in R: plotCI(). Stephan also pointed me to Rseek.org , an excellent search engine for R related queries. I fiddled with Stephan's example code in order to reproduce my SPSS clustered error-bar chart from last week's post on stereotype threat in complex problem solving And this is how I got in in R: I like it very much; the only thing I need to work out is how to offset the bars in the same conditions so that overlapping error bars don't actually overlap but are drawn next to each other with a few pixels between them.If you would like to try this out for yourself, here is the R code that produces the image above: