R Percentiles


Percentiles

Percentiles used in mathematics to give you a number that describes the value that the given percentage is less than that.

If we look at the wt (weight) variable values ​​from the mtcars data set:


Observation of wt (weight)
1.513 1.615 1.835 1.935 2.140 2.200 2.320 2.465
2.620 2.770 2.780 2.875 3.150 3.170 3.190 3.215
3.435 3.440 3.440 3.440 3.460 3.520 3.570 3.570
3.730 3.780 3.840 3.845 4.070 5.250 5.345 5.424

What is 75. motor weight percentile? The answer is 3.61 or 3 610 lbs, which means that 75% or cars weigh 3 310 lbs or less:


Example

Data_Cars <- mtcars

# c() specifies which percentile you want
quantile(Data_Cars$wt, c(0.75))

Result
75% 
    3.61

If you use a quantile() function without specifying a parameter c(), you will get 0, 25, 50, 75 and 100 percent:


Example

Data_Cars <- mtcars

quantile(Data_Cars$wt)

Result
     0%     25%     50%     75%    100% 
    1.51300 2.58125 3.32500 3.61000 5.42400 
    


Quartiles

The quartiles are data divided into four parts, which are arranged in ascending order:

  1. The value of the first quartile cuts off the first 25% of the data
  2. The value of the second quartile cuts off the first 50% of the data
  3. The value of the third quartile cuts off the first 75% of the data
  4. The value of the fourth quartile cuts off the 100% of the data

Use the quantile() function to get the quartiles.