cut_quantiles: Cut vector in n-quantile intervals.

View source: R/utils.R

cut_quantilesR Documentation

Cut vector in n-quantile intervals.

Description

A numeric vector is cut in n-intervals corresponding to quantiles (e.g: for n = 3, the vector is cut by tertiles). A data frame is returned which contains the initial value, the interval assignment and, optionally, the user-provided labeling.

Usage

cut_quantiles(x, n, labels = NULL, right = FALSE)

Arguments

x

a numeric vector.

n

a single numeric defining the number of quantile intervals.

labels

an optional user-provided vector of labels.

right

logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa.

Details

the minimum and maximum values are always included in the first and the last interval, respectively. NAs are silently removed.

Value

A tibble with the initial values in the order as they were provided, the interval assignment and the user-provided labeling.


PiotrTymoszuk/coxExtensions documentation built on Feb. 6, 2024, 10:58 p.m.