Apologies in advance - I'm a bit of a newbie with R but I've been Google-ing this for weeks and I haven't found a straight answer.

The problem

Basically, I'm looking to plot proportions with their confidence intervals on a box and whiskers plot using the R environment.

i.e. Plot the results of binom.test(100,1000) and binom.test(125,1000)

What is the best package (I don't have a preference either way) and way to go about doing this?


This really does look to be more appropriate to an [r] tagged question in SO but there seems to be a surprisingly wide degree of tolerance for such questions in CV, so here goes. The answer also assumes you did not really want to use the existing boxplot() function which is what would be used to construct a true box-and-whiskers plot (and which doesn't really use binomial CI's, but rather uses the Tukey defined fivenum() function ). The plotrix and gplots packages both have what appears to be the same plotCI function;

est1 <- binom.test(100,1000) ; est2 <- binom.test(125,1000)
estvals <- rbind( c(est1$estimate, est1$conf.int[1], est1$conf.int[2]),
                  c(est2$estimate, est2$conf.int[1], est2$conf.int[2]))
plotCI(x = c(1,2), estvals[,1], ui=estvals[,3], li=estvals[,2], 
         xlim=c(0.5,2.5), ylim=c(0, 0.15) , xaxt="n", xlab="Groups")

The basic function is the arrows() plotting function with an argument that splays the points of the arrows to 90 degrees in both directions.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.