[R] Boxplot not doing what I think it should

Greg Snow Greg.Snow at imail.org
Thu Feb 24 19:15:19 CET 2011


Look at ?quantile, especially the detail section on "type" and the second reference (and the see also section).  There are many different definitions of quantiles/quartiles and different functions use different versions.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Lewis Berman
> Sent: Thursday, February 24, 2011 8:38 AM
> To: r-help at R-project.org
> Subject: [R] Boxplot not doing what I think it should
> 
> My box plot below is drawing its upper whisker all the way to the last
> point, instead of showing the point as an outlier. Am I
> misunderstanding, or is it a bug?
> 
> Help(boxplot) states for the parameter "range" that "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."
> 
> To my understanding, the code below, which drew the boxplot, should
> have drawn the right-hand whisker only to 387 and shown 496 as an
> outlier point. But it didn't. Using a range of 1.3 does. Horizontal
> versus vertical does not matter.
> 
> Also, the right edge of the box does not show the same 3rd Quartile as
> does "summary." Explain, please.
> 
> 
> > sort(t5g24times)
> [1] 111 135 201 234 283 283 284 285 300 370 387 496
> > summary(t5g24times)
>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
>   111.0   225.8   283.5   280.8   317.5   496.0
> > iqr <- 317.5 - 225.8
> > iqr
> [1] 91.7
> > 317.5 + 1.5 * iqr
> [1] 455.05
> > pdf()
> > boxplot(c(t5g24times), horizontal=1, range=1.5)
> 
> 
> R version info:
> platform       x86_64-apple-darwin9.8.0
> arch           x86_64
> os             darwin9.8.0
> system         x86_64, darwin9.8.0
> status
> major          2
> minor          12.0
> year           2010
> month          10
> day            15
> svn rev        53317
> language       R
> version.string R version 2.12.0 (2010-10-15)



More information about the R-help mailing list