## ----include = FALSE----------------------------------------------------------
is_sf_ready <- requireNamespace("sf", quietly = TRUE)
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  eval = is_sf_ready
)

## ----setup-packages, message=FALSE, warning=FALSE-----------------------------
library(SurveyNCD)
library(sf)
library(dplyr)

## ----prepare-data, warning=FALSE, message=FALSE-------------------------------
# Load a standard testing shapefile
regional_map <- st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)

# Simulate SurveyNCD output data for specific regions
survey_metrics <- data.frame(
  NAME = c("Ashe", "Alleghany", "Surry", "Currituck"),
  Stunting_Inequality = c(-0.45, -0.20, 0.15, 0.35)
)

## ----generate-map, fig.width=7, fig.height=5----------------------------------
inequality_map <- survey_map_indicator(
  survey_data = survey_metrics,
  shapefile = regional_map,
  join_by = "NAME",
  fill_var = "Stunting_Inequality"
)

# Display the map
print(inequality_map)

