percentile_rank: Percentile ranks with averaged ties

View source: R/percentile_rank.R

percentile_rankR Documentation

Percentile ranks with averaged ties

Description

Converts a vector of measurements into percentile ranks, (\bar{r} - 1/2) / k, where \bar{r} is the average rank (ties share the mean of the ranks they span) and k is the number of measurements ranked. This is the rank scale on which the agreement check of rank_contrasts() compares Jensen-Shannon distance with Pillai: a difference of 0.25 means the two measures place a speaker a quarter of the ordering apart. Ranks are ascending, so larger values of x receive larger percentile ranks. Measurements that are NA or flagged in exclude are left out of the ranking (they do not count toward k) and come back as NA.

Usage

percentile_rank(x, exclude = NULL)

Arguments

x

Numeric vector of measurements to rank.

exclude

Optional logical vector the same length as x: TRUE removes a measurement from the ranking before the ranks are computed. For example, exclude = x >= 0.99 drops Jensen-Shannon distances at the ceiling. NA entries are treated as FALSE.

Value

Numeric vector the same length as x with percentile ranks in (0, 1) for the ranked measurements and NA elsewhere.

Examples

percentile_rank(c(0.2, 0.5, 0.5, 0.9))
percentile_rank(c(0.2, 0.5, 0.5, 0.995), exclude = c(0.2, 0.5, 0.5, 0.995) >= 0.99)

phontrast documentation built on Oct. 7, 2026, 5:06 p.m.