3) Calculate Quartiles and the Interquartile Range.

This Blog entry is from the Summary Statistics and Basic Plots section in Learn R.

Quartiles, which divides the vector up into four chunks which are equally sized, is one means to estimate spread.  The IQR() function allocates the entries in a vector and provides explanation of the thresholds, returning the range between the end of the first quartile and the start of the third quartile.  To establish quartiles type:

IQR(AAPL$Interim_Close)
1.png

Run the line of script to console:

2.png

To obtain more granularity around the range calculated using the IQR() function,  use the quantile() function by typing:

quantile(AAPL$Interim_Close)
3.png

Run the line of script to console:

4.png

The first quartile is 107.510, the second quartile is 171.195 and the third quartile is 392.575, values which provide a measure of spread and coupled with other summary statistics can support a further visualization in the form of a box plot, as explained in later Blog entries.