 InfluentialPoints.com
Biology, images, analysis, design...
 Use/Abuse Principles How To Related
"It has long been an axiom of mine that the little things are infinitely the most important" (Sherlock Holmes)

## Quantiles & boxplots using R

### Quantiles and similar measures

R has a variety of functions that produce quantile-related statistics, most of which are self-explanatory. With a little thought it is possible to produce various other useful measures.

Giving:

 > median(y)  152 > min(y)  43 > max(y)  785 > range(y) # min & max  43 785 > IQR(y) # interquartile range  216 > summary(y) # range, quartiles, & mean Min. 1st Qu. Median Mean 3rd Qu. Max. 43.0 85.0 152.0 213.7 301.0 785.0 > quantile(y,0.1) # first decile (p=0.1) 10% 75 > quantile(y,c(0.05,0.95)) # 90% range 5% 95% 72 455 > rank(y)  17 11 10 8 9 2 20 6 15 14 7 18 21 13 3 4 1 12  16 5 19 > rank(y)/length(y) # relative rank  0.80952381 0.52380952 0.47619048 0.38095238 0.42857143  0.09523810 0.95238095 0.28571429 0.71428571 0.66666667  0.33333333 0.85714286 1.00000000 0.61904762 0.14285714  0.19047619 0.04761905 0.57142857 0.76190476 0.23809524  0.90476190 > # proportion greater than 101 > sum(y > 101)/length(y)  0.6666667  Note:
• By default, if not every value of y is different, the rank function gives their mean rank.
• The last two instructions assume y has no missing values (NA).

### Boxplots   Note, by default boxplots are numbered in the order you provide their data. ### Quantile quantile plots

A useful way to compare the distributions of two sets of values is to plot the quantiles of one set against the corresponding quantiles of the second set. When both sets have the same number of values the easiest way is to plot a scatterplot of their values, arranged in rank-order - but, if they have an unequal number of values, the qqplot function will interpolate as required.       