x <- replicate(20,rnorm(50))
boxplot(x,notch=TRUE,main="Notched boxplot with error bars")
error.bars(x,add=TRUE)
abline(h=0)
#show 50% confidence regions and color each variable separately
error.bars(attitude,alpha=.5,
main="50 percent confidence limits",col=rainbow(ncol(attitude)) )
error.bars(attitude,bar=TRUE) #show the use of bar graphs
#combine with a strip chart and boxplot
stripchart(attitude,vertical=TRUE,method="jitter",jitter=.1,pch=19,
main="Stripchart with 95 percent confidence limits")
boxplot(attitude,add=TRUE)
error.bars(attitude,add=TRUE,arrow.len=.2)
#use statistics from somewhere else
my.stats <- data.frame(values=c(1,4,8),mean=c(10,12,18),se=c(2,3,5))
error.bars(stats=my.stats,type="b",main="data with confidence intervals")
#note that in this case, the error bars are 1 s.e. To modify that, change the s.e.
#Consider the case where we get stats from describe
temp <- describe(attitude)
error.bars(stats=temp)
#these error bars will be just one s.e.
#adjust the s.e. to vary by alpha level
alpha <- .05
temp[,"se"] <- temp[,"se"] * qt(1-alpha/2,temp[,"n"])
error.bars(stats=temp)
#show these do not differ from the other way by overlaying the two
error.bars(attitude,add=TRUE)
Run the code above in your browser using DataLab