dotchartN<-function(x, y, err.bars="ci", pch=16, col=1, length=0.05, las=2, ylab=names(y), xlab = "Group", ...){ x<-as.factor(x) par(mar=c(5,5,2,2)) means<-tapply(y, x, mean) if (err.bars=="se") int<-sqrt(tapply(y, x, var)/(tapply(y, x, length)-1)) if (err.bars=="ci") {int<-sqrt(tapply(y, x, var)/(tapply(y, x, length)-1))*qt(0.975, tapply(y, x, length)-1)} if (err.bars!="range") { maxs<-means+int mins<-means-int } if (err.bars=="range") { maxs<-tapply(y, x, max) mins<-tapply(y, x, min) } ymi<-min(mins) yma<-max(maxs) ymi<-ymi-0.1*(yma-ymi) yma<-yma+0.1*(yma-ymi) plot(1:length(levels(x)), means, ylim=c(ymi, yma), xlim=c(0.5, length(levels(x))+0.5), las=las, xaxt='n', pch=pch, col=col, ylab=ylab, xlab=xlab) axis(1, 1:length(levels(x)), labels=levels(x)) arrows(1:length(levels(x)), y0=mins, y1=maxs, code=3, angle=90, length = 0.05, col=col) }