Measures of variability gives how “spread out” the data are.

Interquartile range

Recall that, quartiles divide the data into 4 parts. Note that, the interquartile range (IQR) - corresponding to the difference between the first and third quartiles - is sometimes used as a robust alternative to the standard deviation.

R function:

quantile(x, probs = seq(0, 1, 0.25))

x : numeric vector whose sample quantiles are wanted.

: numeric vector whose sample quantiles are wanted. probs: numeric vector of probabilities with values in [0,1].





Example:

quantile(my_data$Sepal.Length)

0% 25% 50% 75% 100% 4.3 5.1 5.8 6.4 7.9

By default, the function returns the minimum, the maximum and three quartiles (the 0.25, 0.50 and 0.75 quartiles).

To compute deciles (0.1, 0.2, 0.3, …., 0.9), use this:

quantile(my_data$Sepal.Length, seq(0, 1, 0.1))

To compute the interquartile range, type this:

IQR(my_data$Sepal.Length)