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....@cbs.dk Priv: pda...@gmail.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.