Learn R Programming

lares (version 5.1.0)

quants: Calculate cuts by quantiles

Description

This function lets the user quickly calculate cuts for quantiles and discretize numerical values into categorical values.

Usage

quants(values, splits = 10, return = "labels", n = 2)

Arguments

values

Vector. Values to calculate quantile cuts

splits

Integer. How many cuts should split the values?

return

Character. Return "summary" or "labels"

n

Integer. Determines the number of digits used in formatting the break numbers.

Value

Factor vector or data.frame. Depending on return input:

  • labels a factor ordered vector with each observation's quantile

  • summary a data.frame with information on each quantile cut

See Also

Other Calculus: corr(), dist2d(), model_metrics()

Examples

Run this code
# NOT RUN {
data(dft) # Titanic dataset
quants(dft$Age, splits = 5, "summary")
quants(dft$Age, splits = 5, "labels")[1:10]
# }

Run the code above in your browser using DataLab