qcut: Discretizing a numeric vector

Description Usage Arguments Value Examples

View source: R/qcut.R

Description

The function qcut discretizes a numeric vector into N pieces based on quantiles.

Usage

1
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

1
2
3
4
5
6
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

mob documentation built on July 31, 2021, 9:06 a.m.

Related to qcut in mob...