cut_quantile {svMisc} | R Documentation |
Convert numeric to factor with intervals of equal number of items by using quantiles
Description
cut_quantile()
is like cut()
, but it calculates intervals
from quantiles such that each interval has approximately the same number of
items from the original vector. x
must have both quantile()
and cut()
methods implemented.
Usage
cut_quantile(x, breaks, labels = NULL, ...)
Arguments
x |
An R object, usually a numeric vector. |
breaks |
A single integer with the number of breaks to use. |
labels |
Labels for the resulting category or |
... |
Further arguments passed to |
Value
A factor()
is returned, unless labels = FALSE
(in this case, a
integer vector is obtained).
Examples
# Transform a numeric vector into a factor with 5 levels of same item numbers
vec <- rnorm(20)
fact <- cut_quantile(vec, breaks = 5)
fact
table(fact)
[Package svMisc version 1.4.3 Index]