Skip to contents

Vectorized version of base::cut() that allows each entry in the vector to use different break points and labels.

Usage

categorize_vector(
  values,
  break_sets,
  label_sets,
  include.lowest = TRUE,
  order = TRUE,
  right = TRUE,
  ...
)

Arguments

values

Vector of values to categorize.

break_sets

sets of category breakpoints, with one set for each entry of values, as a list of numeric vectors. Alternatively, a single set of category breakpoints to use for all values, as a one-entry list containing a single numeric vector.

label_sets

sets of labels to associate, with the corresponding breakpoints in break_sets, with one set for each entry of values, as a list of character vectors. Alternatively, a single set of labels to use for all values, as a one-entry list containing a single character vector.

include.lowest

Passed to base::cut(). Default TRUE.

order

Passed to base::cut(). Default TRUE.

right

Passed to base::cut(). Default TRUE.

...

Additional keyword arguments passed to base::cut().

Value

A categorized vector, as vector of ordered factors.