Skip to content
Prev 33262 / 63424 Next

box and whisker (PR#13821)

m.crawley at imperial.ac.uk wrote:
Not according to the docs:

    range: this determines how far the plot whiskers extend out from the
           box.  If 'range' is positive, the whiskers extend to the most
           extreme data point which is no more than 'range' times the
           interquartile range from the box. A value of zero causes the
           whiskers to extend to the data extremes.

And the code itself has

             stats[c(1, 5)] <- range(x[!out], na.rm = TRUE)

So the whisker won't be equal to 1.5 IQR unless there happens to be an 
observation there.

Now, this might be wrong, but people have tried very hard to make the 
implementation follow the original definition due to Tukey. I.e., if you 
can point out that Tukey specified it otherwise, then we'd change it, 
otherwise it is just not a bug.
For easier reproduction (reproducible examples should not refer to files 
on your C: drive...):

 > diff(boxplot({set.seed(9);x<-rnorm(50)})$stats)
           [,1]
[1,] 1.2525857
[2,] 0.5412128
[3,] 0.6083348
[4,] 1.4625057