classification_helpers | R Documentation |
These functions extract different components from mapgl_classification objects
(created by step_equal_interval()
, step_quantile()
, step_jenks()
) and
mapgl_continuous_scale objects (created by interpolate_palette()
).
get_legend_labels(
scale,
format = "none",
currency_symbol = "$",
digits = 2,
big_mark = ",",
suffix = "",
prefix = ""
)
get_legend_colors(scale)
get_breaks(scale)
## S3 method for class 'mapgl_classification'
print(x, format = "none", ...)
## S3 method for class 'mapgl_continuous_scale'
print(x, format = "none", ...)
scale |
A mapgl_classification or mapgl_continuous_scale object. |
format |
A character string specifying the format type for labels. Options include:
|
currency_symbol |
The currency symbol to use when format = "currency". Defaults to "$". |
digits |
The number of decimal places to display. Defaults to 2. |
big_mark |
The character to use as thousands separator. Defaults to ",". |
suffix |
An optional suffix to add to all values (e.g., "km", "mph"). |
prefix |
An optional prefix to add to all values (useful for compact currency like "$1.2K"). |
x |
A mapgl_classification or mapgl_continuous_scale object to print. |
... |
Additional arguments passed to formatting functions. |
A character vector of formatted legend labels
A character vector of colors
A numeric vector of break values
## Not run:
# Texas county income data
library(tidycensus)
tx <- get_acs(geography = "county", variables = "B19013_001",
state = "TX", geometry = TRUE)
# Classification examples
eq_class <- step_equal_interval("estimate", tx$estimate, n = 4)
labels <- get_legend_labels(eq_class, format = "currency")
colors <- get_legend_colors(eq_class)
breaks <- get_breaks(eq_class)
# Continuous scale examples
scale <- interpolate_palette("estimate", tx$estimate, method = "quantile", n = 5)
labels <- get_legend_labels(scale, format = "compact", prefix = "$")
colors <- get_legend_colors(scale)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.