Skip to content
Prev 31868 / 398513 Next

what does boxplot draw?

Dear r-help,

   Unfortunately I cannot find in the documentation what determines
   ranges of a 'box' in the box-and-whisker plot.
   
   It is said in "Simple R" (http://www.math.csi.cuny.edu/Statistics/R/simpleR)
   that they are 1st and 3rd Qus usually.

   I tried to add to boxplot lines with (quantile(x,probs=0.25)), but
   lines do not coincide with edges of boxes.

Here's the example. I've got 3 vectors of values, x1,x2,x3

The command

boxplot(list(x1,x2,x3))

draws 3 box-and-whisker diagrams.

Commands

lines(c(quantile(x1,probs=c(0.25)),quantile(x2,probs=c(0.25)),quantile(x3,probs=c(0.25))))
lines(c(quantile(x1,probs=c(0.75)),quantile(x2,probs=c(0.75)),quantile(x3,probs=c(0.75))))

draw lines with y values of quantiles.
Lines ends are close to the box edges but not exactly on them.
While command

lines(c(median(x1),median(x2),median(x3)))

puts lines with ends exactly on the middle line of the box-and-whisker
plots.