| attach_geometry | R Documentation |
Adds geometry for mapping. Auto-detects state or district level from available columns.
attach_geometry(
data,
year,
geography = NULL,
unmatched = c("warn", "error", "ignore")
)
data |
A data frame containing census data with state/district names. |
year |
Census year for boundaries. Available: 1941, 1951, 1961, 1971, 1981, 1991, 2001, 2011. |
geography |
Geographic level: "state" or "district". If NULL (default), auto-detects based on available columns. |
unmatched |
What to do when rows get no geometry, or when two rows are
given the same polygon: |
An sf object with geometry attached.
Boundary files are downloaded on first use; see census_cache_dir().
# Attach district boundaries
census_2011_pca |>
dplyr::mutate(st_pct = 100 * st_population / population_total) |>
attach_geometry(2011)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.