Skip to contents

This function provides a convenient method to calculate a percentile value from a numeric vector. The vector, x, is ranked in ascending order and the nth percentile value is inferred by linear interpolation.

Usage

mqo_percentile(x, quantile = 0.9, na.rm = FALSE)

Arguments

x

A numeric vector from which to calculate a percentile value.

quantile

A quantile value between 0 and 1. The default, 0.9, calculates the 90th percentile.

na.rm

logical; if true, any NA and NaN's are removed from x before the quantiles are computed.

See also

Author

Jack Davison

Examples

mqis <- seq(0.1, 1, by = 0.1)

mqo_percentile(mqis)
#> [1] 0.9

mqo_percentile(mqis[1:9])
#> [1] 0.81