Skip to contents

Discretize a continuous variable into quantiles

Usage

qcut(x, q = c(0.25, 0.5, 0.75), ...)

Arguments

x

Numeric

q

Probabilities. Should be 1 less than the number of discrete bins to be returned. x is cut from left-to-right, filling up the smallest bin first. For example, c(.25, .50, .75) returns a factor of 4 levels - 0%-25%, 25%-50%, 50%-75%, 75%-100%. Bins are left-inclusive and right-exclusive.

...

Passed to stats::quantile

Value

Examples

qcut(1:100, c(.2, .4, .6, .8))
#>   [1] "0%"  "0%"  "0%"  "0%"  "0%"  "0%"  "0%"  "0%"  "0%"  "0%"  "0%"  "0%" 
#>  [13] "0%"  "0%"  "0%"  "0%"  "0%"  "0%"  "0%"  "0%"  "20%" "20%" "20%" "20%"
#>  [25] "20%" "20%" "20%" "20%" "20%" "20%" "20%" "20%" "20%" "20%" "20%" "20%"
#>  [37] "20%" "20%" "20%" "20%" "40%" "40%" "40%" "40%" "40%" "40%" "40%" "40%"
#>  [49] "40%" "40%" "40%" "40%" "40%" "40%" "40%" "40%" "40%" "40%" "40%" "40%"
#>  [61] "60%" "60%" "60%" "60%" "60%" "60%" "60%" "60%" "60%" "60%" "60%" "60%"
#>  [73] "60%" "60%" "60%" "60%" "60%" "60%" "60%" "60%" "80%" "80%" "80%" "80%"
#>  [85] "80%" "80%" "80%" "80%" "80%" "80%" "80%" "80%" "80%" "80%" "80%" "80%"
#>  [97] "80%" "80%" "80%" "80%"