Sunday, November 16, 2014

Quartiles in R

In this Wikipedia article it looks like the R functions summary and fivepoint use the same algorithm to calculate q1 and q3:
image
However that is not the case, as can be seen here (notice the difference in q1 and q3):
image
Of course quartiles are not uniquely defined. In fact the function quantile offers nine(!) different ways to calculate them: http://stat.ethz.ch/R-manual/R-patched/library/stats/html/quantile.html. The function summary actually calls quantile using its default algorithm type 7.