powered by
The function qcut discretizes a numeric vector into N pieces based on quantiles.
qcut
qcut(x, n)
A numeric vector.
An integer indicating the number of categories to discretize.
A numeric vector to divide the vector x into n categories.
# NOT RUN { 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 # }
Run the code above in your browser using DataLab