## two-way error bars
tmp <- data.frame(x1.mean=1:6, x1.sd=(7:12),
y1.mean=1:6, y1.sd=(7:12),
x2.mean=13:18, x2.sd=(7:12),
y2.mean=13:18, y2.sd=(7:12),
n=21:26,
a=c(1:3,1:3), b=c(1,1,1,2,2,2))
tmp1 <- tmp[,c(1,2,3,4, 9,10,11)]
names(tmp1)[1:4] <- c("x.mean","x.sd","y.mean","y.sd")
tmp2 <- as.list(tmp[,c(5,6,7,8, 9,10,11)])
names(tmp2) <- NULL
tmp.data <- rbind(tmp1,tmp2)
tmp.data$group <- c(1,1,1,1,1,1, 2,2,2,2,2,2)
tmp.data
xyplot(y.mean ~ x.mean | a*b, groups=group, data=tmp.data,
critical.dist=qt, conf=.95,
panel=function(x, y, subscripts, groups, critical.dist, conf, ...) {
panel.superpose(x, y, subscripts, groups, ...)
tds <- tmp.data[subscripts,]
critical <- critical.dist(1-(1-conf)/2, tds$n-1)
segments(x1=tds$x.mean - critical*tds$x.sd/sqrt(tds$n),
x2=tds$x.mean + critical*tds$x.sd/sqrt(tds$n),
y1=tds$y.mean, y2=tds$y.mean)
segments(y1=tds$y.mean - critical*tds$y.sd/sqrt(tds$n),
y2=tds$y.mean + critical*tds$y.sd/sqrt(tds$n),
x1=tds$x.mean, x2=tds$x.mean)
})
## I have some data to plot using xyplot. They were produced by a 5x2x2
## factorial design. How can I cause the trellis to have a 5x4 layout,
## with the leftmost two columns being the 5x2 for the first value of the
## third factor, and the rightmost two columns being the 5x2 for the second
## value of the third factor?
tmp <- data.frame(x=rnorm(20), y=rnorm(20),
fac.design(c(5,2,2), letters[1:3]))
xyplot(y ~ x | b*c*a, data=tmp, layout=c(4,5),
between=list(x=c(0,1,0)),
par.strip.text=list(cex=1))
|