In R, there are various ways to find the lower quartile of $n = 48$ observations. However, you need to know it is not always obvious how to find sample percentiles, especially for small samples or where there are lots of ties.
The default method in R of finding quantiles is one of several available methods, which you can read about in R documentation, and choose the one you want to use.
Suppose you have $n = 48$ normal observations, rounded to two-places:
set.seed(121)
x = round(rnorm(48, 100, 15),2)
sort(x)
[1] 73.77 77.96 78.89 82.62 82.92 83.51
[7] 86.94 87.08 87.89 88.67 89.29 90.88
[13] 91.51 91.93 92.97 93.99 95.98 96.17
[19] 96.84 98.78 99.14 99.38 99.77 101.09
[25] 101.63 101.92 103.16 104.46 104.52 105.56
[31] 106.35 107.10 107.53 108.17 109.56 109.65
[37] 109.98 110.11 110.72 110.81 111.73 113.61
[43] 113.70 115.01 118.24 120.66 121.04 124.23
Just looking at the sorted list, you might guess that
the lower quartile would be somewhere between 90.88 and 91.51. Halfway between is 91.245, but R chooses the number 91.3525, which is a little closer to 91.51.
Here are three ways in R to get the 25th percentile or lower quartile:
summary(x)
Min. 1st Qu. Median Mean 3rd Qu. Max.
73.77 91.35 101.36 100.36 109.73 124.23
quantile(x)
0% 25% 50% 75% 100%
73.7700 91.3525 101.3600 109.7325 124.2300
quantile(x, .25)
25%
91.3525
The type
of method that is the default in R is
type=7
, but different types give slightly different
answers, as shown below:
quantile(x, .25, type=5)
25%
91.195
quantile(x, .25, type=6)
25%
91.0375
quantile(x, .25, type=7)
25%
91.3525 # Default
quantile(x, .25, type=8)
25%
91.1425
All of the types have advocates who have different
uses for quantiles in various fields of application.
If you are a student, use whatever method of finding
quantiles is standard in your class.
Quantiles are often used in practice with very large
datasets, for which the types tend to give very nearly
the same results. In practice, this 'quirkiness` in methods of finding quantiles
is more of a curiosity than a difficulty.