cut: Cut numeric vector into factor vector

View source: R/cut.R

cutR Documentation

Cut numeric vector into factor vector

Description

\Sexpr[results=rd]{lifecycle::badge("stable")}

Usage

cut(x, at, label = NULL, ...)

Arguments

x

A numeric vector to be cut into factors.

at

A numeric vector specifying the breakpoints or categories for cutting the vector. If a single value is provided, the function will create breaks using the same method as ⁠[base::cut]⁠. If multiple values are provided, they are treated as specific breaks.

label

Optional labels for the resulting factor levels. If not provided, labels will be automatically generated based on the breaks.

...

Additional arguments to be passed to ⁠[base::cut]⁠ if x is not numeric.

Details

This function cuts a numeric vector into factors based on specified breaks or categories. If the input vector is not numeric, the function delegates to the base R cut function.

Value

A factor representing the cut vector with factor levels assigned based on the breaks or categories.

See Also

Other Data Management: append(), codebook(), count_functions, tag_duplicates()

Examples

x <- c(1, 2, 3, 4, 5)
cut(x, 2)

myominnoo/mStats documentation built on Nov. 29, 2023, 2:36 a.m.