jenks: Quickly cut a vector with the Jenks/Fisher algorithms

View source: R/jenks.R

jenksR Documentation

Quickly cut a vector with the Jenks/Fisher algorithms

Description

Given a numeric vector, this returns a factor of those values cut into n number of breaks using the Jenks/Fisher algorithms. The algorithm(s) sets breaks in a way that highlights very high or very low values well. It's good to use for choropleths that need to convey imbalances or inequities.

Usage

jenks(x, n = 5, true_jenks = FALSE, labels = NULL, ...)

Arguments

x

A numeric vector to cut

n

Number of bins, Default: 5

true_jenks

Logical: should a "true" Jenks algorithm be used? If false, uses the faster Fisher-Jenks algorithm. See classInt::classIntervals docs for discussion. Default: FALSE

labels

A string vector to be used as bin labels, Default: NULL

...

Additional arguments passed on to base::cut

Value

A factor of the same length as x

See Also

classInt::classIntervals

Examples

 set.seed(123)
 values <- rexp(30, 0.8)
 jenks(values, n = 4)

CT-Data-Haven/cwi documentation built on July 1, 2024, 7:45 a.m.