pctiles | R Documentation |
Get a quick look at a distribution by seeing the 100 values that are the percentiles 1-100
pctiles(x, probs = (1:100)/100, na.rm = TRUE, digits = 3)
x |
Required numeric vector of values whose distribution you want to look at. |
probs |
Optional vector of fractions specifying percentiles. (1:100)/100 by default. |
na.rm |
TRUE by default, specifies if NA values should be removed first. |
digits |
Number, 3 by default, how many decimal places to round to |
Returns a data.frame
This is how should be calculating percentiles as of 2/2013.
*** WARNING: Unless set type=1, the default type=7 in which case stats::quantile() FUNCTION INTERPOLATES, WHICH ISN'T OBVIOUS IN EVERY DATASET!
use type=1 to avoid interpolation.
and pctiles() rounded results so interpolation would be even less apparent.
The quantile function will NOT interpolate between values if type=1:
stats::quantile(1:12, probs=(1:10)/10, type=1)
10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
2 3 4 5 6 8 9 10 11 12
###########################
**** IMPORTANT ***
###########################
*** WARNING: The wtd.quantile function DOES interpolate between values, even if type='i/n'
There does not seem to be a way to fix that for the wtd.quantile() function.
For example,
wtd.quantile(1:12, probs=(1:10)/10, type='i/n', weights=rep(1,12))
10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
1.2 2.4 3.6 4.8 6.0 7.2 8.4 9.6 10.8 12.0
pctiles()
pctiles.exact()
pctiles.a.over.b()
wtd.pctiles.exact()
wtd.pctiles()
wtd.pctiles.fast()
#
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.