View source: R/quantile_group.R
quantile_group | R Documentation |
Transforms a numeric vector into quantile groups. For each input value, the output value corresponds to the quantile that value is in. When grouping into n quantiles, the lowest 1/n of values are assigned 1, the highest 1/n are assigned n.
quantile_group(data, n, na.rm = TRUE)
data |
a vector of type numeric with values to be grouped into quantiles |
n |
integer indicating number of quantiles, minimum of 2. Must be smaller than length(data) |
na.rm |
logical; if TRUE all NA values will be removed before calculating groups, if FALSE no NA values are permitted. |
Tied values will be assigned to the lower quantile group rather than etsimating a distribution. In extreme cases this can mean one or more quantile groups are not represented.
If uneven group sizes cannot be avoided, values will be assigned the higher quantile group.
vector of length length(data) with the quantile groups
J. Peter Marquardt
quantile_group(10:1, 3)
quantile_group(c(rep(1,3), 10:1, NA), 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.