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

...

Arguments passed on to base::cut

Value

A factor of the same length as x

See Also

classInt::classIntervals()

Other utils: batch_csv_dump(), check_cb_avail(), fix_cogs(), separate_acs(), town_names()

Examples

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

CT-Data-Haven/cwi documentation built on Feb. 27, 2025, 10:46 a.m.