data(simdat)
# averages per condition:
subj <- with(simdat, aggregate(Y,
list(Group=Group, Condition=Condition, Subject=Subject), mean))
avg <- with(subj, tapply(x, list(Group, Condition), mean))
ses <- with(subj, tapply(x, list(Group, Condition), se))
# barplot of Adults:
b <- barplot(avg['Adults',], beside=TRUE)
# overlay addbars:
add_bars(b, avg['Children',], density=25)
# or some variants:
b <- barplot(avg['Adults',], beside=TRUE)
add_bars(b+.1, avg['Children',], col=alpha('red'))
# also the option to make your own type of plot:
emptyPlot(c(-10,10), c(-2,5), v0=0, ylab="Condition")
add_bars(-1*avg["Children",], -1:4, y0=0, col=alpha("blue"),
border="blue", horiz=TRUE)
add_bars(avg["Adults",], -1:4, y0=0, col=alpha("black"),
border=1, horiz=TRUE, xpd=TRUE)
mtext(c("Children", "Adults"), side=3, at=c(-5,5), line=1, cex=1.25, font=2)
Run the code above in your browser using DataLab