[R] Adding error bars to xyplot()

Jon Zadra jrz9f at virginia.edu
Thu Apr 22 00:24:08 CEST 2010


Hi,

I want to add error bars to a plot generated with xyplot.  I've tried 
both errbar() and plotCI(), but in both cases the points are not in the 
same place.  It's as if the two functions are using a different frame of 
reference for the plotting area.

for example:
means <- c(92.5, 92.25, 90.9, 91.0, 94.15, 90.05) #means
time <- c(1,1,2,2,3,3) #occasion variable
group <- rep(c("n","u"),3) #grouping variable
SE <- c(2.22, 1.66, 2.10, 1.43, 2.31, 1.57) #standard errors

#Plot the graph
xyplot(means ~ time, groups=group, type="o", lwd=3, main="Change Over 
Time by Condition", scale=list(cex=2), xlab="Test Number", auto.key=T)

#first attempt
require(Hmisc)
errbar(x = time, y = means, yplus = means + SE, yminus = means - SE, 
add=T, col=c("blue", "hotpink"))

#second attempt, same result
require(gplots)
plotCI(x = time, y = means, uiw = SE, add=T)


Thanks in advance!

- Jon

-- 
Jon Zadra
Department of Psychology
University of Virginia
P.O. Box 400400
Charlottesville VA 22904
(434) 982-4744
email: zadra at virginia.edu
<http://www.google.com/calendar/embed?src=jzadra%40gmail.com>



More information about the R-help mailing list