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.
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::cutbreakseither a numeric vector of two or more unique cut points or a single number (greater than or equal to 2) giving the number of intervals into which
xis to be cut.include.lowestlogical, indicating if an ‘x[i]’ equal to the lowest (or highest, for
right = FALSE) ‘breaks’ value should be included.rightlogical, indicating if the intervals should be closed on the right (and open on the left) or vice versa.
dig.labinteger which is used when labels are not given. It determines the number of digits used in formatting the break numbers.
ordered_resultlogical: should the result be an ordered factor?
Examples
set.seed(123)
values <- rexp(30, 0.8)
jenks(values, n = 4)
#> [1] (0.535,1.36] (0.535,1.36] (1.36,2.71] [0.0364,0.535] [0.0364,0.535]
#> [6] [0.0364,0.535] [0.0364,0.535] [0.0364,0.535] (2.71,5.05] [0.0364,0.535]
#> [11] (0.535,1.36] (0.535,1.36] [0.0364,0.535] [0.0364,0.535] [0.0364,0.535]
#> [16] (0.535,1.36] (1.36,2.71] (0.535,1.36] (0.535,1.36] (2.71,5.05]
#> [21] (0.535,1.36] (0.535,1.36] (1.36,2.71] (1.36,2.71] (1.36,2.71]
#> [26] (1.36,2.71] (1.36,2.71] (1.36,2.71] [0.0364,0.535] (0.535,1.36]
#> Levels: [0.0364,0.535] (0.535,1.36] (1.36,2.71] (2.71,5.05]
