Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is my data set: 5, 8, 12, 42, 43

I am trying to work out the first quartile. When using R (the programming language) it shows the 1st quartile as 8, but when I work it out manually, it shows it as 6.5.

Here's how I am working it out:

First I work out the 25%

25/100 * (5 + 1)

Which is:


There is no value at 1.5, so I do the following to get the average:

(5 + 8) / 2

Which equals:


Where am I going wrong?

share|cite|improve this question
up vote 0 down vote accepted

There are 9 methods defined for computing quantiles, see the help page for quantile in R for the details. You can choose between them using the type argument, the default is 7.

Your method corresponds to type 6 (and is that used by Minitab and SPSS):

x <- c(5, 8, 12, 42, 43)
sapply(1:9, function(y) quantile(x,type=y))["25%",,drop=FALSE]
    [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]   [,9]
25%    8    8    5 5.75 7.25  6.5    8    7 7.0625

Each method uses a different weighted average of consecutive order statistics. The methods are defined in Hyndman, R. J. and Fan, Y. (1996) Sample quantiles in statistical packages, American Statistician, 50, 361–365.

share|cite|improve this answer
Thank you James for clearing that up. I thought I was doing something wrong. – James Jeffery Dec 31 '13 at 13:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.