Cut numeric vector into factor vector
cut.Rd
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]
ifx
is not numeric.
Value
A factor representing the cut vector with factor levels assigned based on the breaks or categories.
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.
See also
Other Data Management:
append()
,
codebook()
,
count_functions
,
tag_duplicates()
Examples
x <- c(1, 2, 3, 4, 5)
cut(x, 2)
#> [1] 1-2 1-2 3-5 3-5 3-5
#> Levels: 1-2 3-5