An R Introduction to Statistics


The nth percentile of an observation variable is the value that cuts off the first n percent of the data values when it is sorted in ascending order.


Find the 32nd, 57th and 98th percentiles of the eruption durations in the data set faithful.


We apply the quantile function to compute the percentiles of eruptions with the desired percentage ratios.

> duration = faithful$eruptions     # the eruption durations 
> quantile(duration, c(.32, .57, .98)) 
   32%    57%    98% 
2.3952 4.1330 4.9330


The 32nd, 57th and 98th percentiles of the eruption duration are 2.3952, 4.1330 and 4.9330 minutes respectively.


Find the 17th, 43rd, 67th and 85th percentiles of the eruption waiting periods in faithful.


There are several algorithms for the computation of percentiles. Details can be found in the R documentation via help(quantile).