Consider any dataset, sort its entries from smallest to largest and split the resulting list in 4 equal subsets. The quartiles are the values of the dataset that cut it off in 4.
Quartiles are called:
In addition, one also refers to:
For info, note that the set of data between Q1 and Q3 (which contains the middle 50% of the data) is the interquartile range (IQR).
In R, quartiles may be obtained using the function quantile()
(NB: this is not a typo, it is quaNtile and not quaRtile, there is a good explanation for it, believe meβ¦). If you choose to use only quantile()
with no other argument than the vector containing the dataset, R returns Q0, Q1, Q2, Q3, Q4 and Q5:
my.dataset <- c(1,2,3,4,5,6,7,8,9,10)
quantile(my.dataset)
## 0% 25% 50% 75% 100%
## 1.00 3.25 5.50 7.75 10.00
If you only need Q1, Q2 and Q3, say it using decimals as follows:
quantile(my.dataset, c(0.25, 0.5, 0.75))
## 25% 50% 75%
## 3.25 5.50 7.75