Learn R Programming

MLmorph (version 0.1.1)

factorize_numeric_vector: Turn numeric vector into an ordered factor

Description

Turn numeric vector into an ordered factor

Usage

factorize_numeric_vector(
  data_vector,
  method = c("equal_bins", "equal_distance", "custom_breaks"),
  breaks_no = 5,
  custom_breaks = NULL,
  custom_labels = NULL
)

Value

An ordered factor with interval labels.

Arguments

data_vector

Numeric vector.

method

Factorization rule: one of "equal_bins", "equal_distance", "custom_breaks".

breaks_no

Integer \(\ge 2\); number of intervals when method != "custom_breaks".

custom_breaks

Optional numeric vector of cut points (strictly increasing) used when method = "custom_breaks".

custom_labels

Optional character vector of labels. If supplied, its length should equal length(custom_breaks) - 1.

Examples

Run this code
factorize_numeric_vector(runif(10))

Run the code above in your browser using DataLab