Learn R Programming

mark (version 0.8.1)

percentile_rank: Percentile rank

Description

The bounds of the percentile rank are > 0 and < 1 (see Boundaries)

A percentile rank here is the proportion of scores that are less than the current score.

$$PR = (c_L + 0.5 f_i) / N$$

Where

\(c_L\) is the frequency of scores less than the score of interest

\(f_i\) is the frequency of the score of interest

Usage

percentile_rank(x, weights = times, times)

Value

The percentile rank of x between 0 and 1 (see Boundaries)

Arguments

x

A vector of values to rank

weights, times

A vector of the number of times to repeat x

Boundaries

While the percentile rank of a score in a set must be exclusively within the boundaries of 0 and 1, this function may produce a percentile rank that is exactly 0 or 1. This may occur when the number of values are so large that the value within the boundaries is too small to be differentiated.

Additionally, when using the weights parameter, if the lowest or highest number has a value of 0, the number will then have a theoretical 0 or 1, as these values are not actually within the set.

Details

Computes a percentile rank for each score in a set.

Examples

Run this code
percentile_rank(0:9)
x <- c(1, 2, 1, 7, 5, NA_integer_, 7, 10)
percentile_rank(x)

if (package_available("dplyr")) {
  dplyr::percent_rank(x)
}

# with times
percentile_rank(7:1, c(1, 0, 2, 2, 3, 1, 1))

Run the code above in your browser using DataLab