There's a function for that! classInf::classIntervasl()
library(classInt)
if (!require("spData", quietly=TRUE)) {
message("spData package needed for examples")
run <- FALSE
} else {
run <- TRUE
}
#> To access larger datasets in this package, install the spDataLarge
#> package with: `install.packages('spDataLarge',
#> repos='https://nowosad.github.io/drat/', type='source')`
if (run) {
print(classIntervals(jenks71$jenks71, n=5, style="quantile"))
}
#> style: quantile
#> one of 3,921,225 possible partitions of this variable into 5 classes
#> [15.57,33.822) [33.822,50.114) [50.114,57.454) [57.454,73.368) [73.368,155.3]
#> 21 20 20 20 21
Created on 2020-04-02 by the reprex package (v0.3.0)