qcut {mob} | R Documentation |
Discretizing a numeric vector
Description
The function qcut
discretizes a numeric vector into N pieces based
on quantiles.
Usage
qcut(x, n)
Arguments
x |
A numeric vector. |
n |
An integer indicating the number of categories to discretize. |
Value
A numeric vector to divide the vector x into n categories.
Examples
x <- 1:10
# [1] 1 2 3 4 5 6 7 8 9 10
v <- qcut(1:10, 4)
# [1] 3 5 8
findInterval(x, sort(c(v, -Inf, Inf)), left.open = TRUE)
# [1] 1 1 1 2 2 3 3 3 4 4
[Package mob version 0.4.2 Index]