classify | R Documentation |
This function discretize a numeric vector into an interval factor
classify(x, n, style = "equal", label = scales::comma_format())
x |
input vector (numeric) |
n |
number of intervals |
style |
"equal", "quantile", "jenks" |
label |
a vectorized function that formats numbers. |
library(ggplot2) library(sf) nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE) ggplot(nc) + geom_sf(aes(fill = classify(AREA, 3, style ="jenks", label = scales::comma_format(accuracy = 0.01))))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.