[R] Quantiles in boxplot‏

René Brinkhuis rene.brinkhuis at live.nl
Sat Jan 14 22:16:10 CET 2012


Thanks for your reaction!
Nice description of the 'hinges' and beautiful compact code.

R.

Attachment:
- updated document on quartiles in R

> Subject: Re: [R] Quantiles in boxplot‏
> From: pdalgd at gmail.com
> Date: Sat, 14 Jan 2012 17:40:09 +0100
> CC: r-help at r-project.org
> To: rene.brinkhuis at live.nl
> 
> 
> On Jan 14, 2012, at 16:07 , René Brinkhuis wrote:
> 
> > 
> > Based
> > on your information I created a custom function for calculating the 
> > first and third quartile according to the 'boxplot logic'.
> 
> A more compact (though not as readable) version is afforded by stats:::fivenum.
> 
> A convenient description is (I believe) that the hinges are the medians of the bottom and top halves of the sorted observations, with the middle observation counting in both groups if n is odd).
> 
> > x <- rnorm(121)
> > fivenum(x)
> [1] -2.4596038 -0.6034689  0.1105829  0.6686026  2.2580863
> > median(sort(x)[1:floor((length(x)+1)/2)])
> [1] -0.6034689
> > median(sort(x)[ceiling((length(x)+1)/2):length(x)])
> [1] 0.6686026
> 
> -- 
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com
> 
> 
> 
> 
> 
> 
> 
> 
 		 	   		  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Quartiles in R.pdf
Type: application/pdf
Size: 48903 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120114/7f21a13e/attachment.pdf>


More information about the R-help mailing list