| choropleth_ggplot2 | R Documentation |
Creates a choropleth map from an object of class sf.
If the chosen variable can be classified into discrete intervals using
Fisher's natural breaks, the polygons are shaded by cluster. Otherwise,
the variable is visualized on a continuous scale.
choropleth_ggplot2(
sf_object,
value = output,
n = 7,
dig.lab = 2,
legend_title = "Class",
option = "D",
direction = 1
)
sf_object |
An object of class |
value |
Column in |
n |
Integer. Number of clusters to use in Fisher classification (default = 7). |
dig.lab |
Integer. Number of digits to display in legend labels (default = 2). |
legend_title |
Character. Title for the legend (default = "Class"). |
option |
Character string indicating the colormap option passed to
|
direction |
Numeric. Order of colors in the scale.
If |
The function first attempts to classify the chosen variable into
n clusters using Fisher's natural breaks
(classInt::classIntervals()). If this fails (e.g. due to insufficient
unique values), the function falls back to a continuous scale.
A ggplot object containing the choropleth map.
Martin Haringa
test <- points_to_polygon(
nl_postcode2,
insurance,
sum(amount, na.rm = TRUE)
)
choropleth_ggplot2(test, value = output)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.