Skip to contents

Mirrors the C# Statistics.Percentile: zero-based linear interpolation (R quantile() Type 7).

Usage

percentile(x, probs, sorted = FALSE)

Arguments

x

numeric vector.

probs

numeric vector of probabilities in [0, 1].

sorted

set TRUE when x is already sorted ascending, to skip re-sorting it.

Value

a numeric vector, one percentile per entry of probs.

Examples

percentile(c(1, 2, 3, 4, 5), probs = c(0.25, 0.5, 0.75))
#> [1] 2 3 4