compare_maps: Compare maps across years

View source: R/plotting.R

compare_mapsR Documentation

Compare maps across years

Description

Compare maps across years

Usage

compare_maps(
  data_list,
  fill_var,
  title = NULL,
  ncol = NULL,
  palette = "viridis",
  common_scale = TRUE,
  show_state_boundaries = TRUE,
  ...
)

Arguments

data_list

A named list of sf data frames, with names as years

fill_var

The variable to map (string)

title

Overall title for the combined plot

ncol

Number of columns for arrangement

palette

Color palette (see plot_map for options)

common_scale

Logical. Use the same color scale across all maps?

show_state_boundaries

Logical. Overlay state boundaries?

...

Additional arguments passed to plot_map

Value

A patchwork object

Examples


# Compare ST percentage across years
library(dplyr)

st_1971 <- census_1971 |>
  filter(geography == "district") |>
  mutate(st_pct = 100 * st_population_total / population_total) |>
  attach_geometry(1971)

st_2011 <- census_2011_pca |>
  mutate(st_pct = 100 * st_population / population_total) |>
  attach_geometry(2011)

# Compare
compare_maps(
  list("1971" = st_1971, "2011" = st_2011),
  fill_var = "st_pct",
  title = "ST Population % by District",
  palette = "red_blue"
)


censusindia documentation built on Oct. 15, 2026, 5:08 p.m.