The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
This vignette shows you how to prepare the data needed to run a
transformation audit with shellgame.
You need three things:
Use the zctaCrosswalk package to find ZCTAs for your
county:
# https://github.com/chris-prener/uds-mapper
# Read the file
zip_zcta_raw <- read.csv("ZiptoZCTA-Table 1.csv")
# Clean and standardize
zip_zcta <- prep_zip_zcta(zip_zcta_raw)What this does: - Standardizes column names - Pads GEOIDs to 5 digits - Removes duplicates and NAs
Download from: https://www.huduser.gov/portal/datasets/usps_crosswalk.html
Select the most recent quarter (e.g., Q4 2024).
# Read the file
hud_raw <- read.csv("ZIP_COUNTY_122024.csv")
# Clean and standardize
hud <- prep_hud_crosswalk(hud_raw)
# Optional: use different ratio
hud_res <- prep_hud_crosswalk(hud_raw, ratio_col = "RES_RATIO")Available ratios: - TOT_RATIO - Total
addresses (default) - RES_RATIO - Residential addresses
only - BUS_RATIO - Business addresses only -
OTH_RATIO - Other addresses
This is Decision #2: Which ratio you choose affects your results.
Here’s the complete workflow in one block:
library(geoDeltaAudit)
library(zctaCrosswalk)
library(tidycensus)
# Set your Census API key (one time)
census_api_key("YOUR_KEY_HERE", install = TRUE)
# 1. Identify ZCTAs for your county
zctas <- get_zctas_by_county("YOUR_COUNTY_FIPS")
# 2. Get baseline data
baseline_data <- get_zcta_baseline(
variable = "B01001_001", # Total population
year = 2022,
zctas = zctas
)
# 3. Prepare crosswalks
zip_zcta <- prep_zip_zcta(read.csv("path/to/ZiptoZCTA.csv"))
hud <- prep_hud_crosswalk(read.csv("path/to/ZIP_COUNTY.csv"))
# 4. Run audit
result <- audit_transformation(
baseline_data = baseline_data,
zip_zcta_map = zip_zcta,
hud_crosswalk = hud,
county_fips = "YOUR_COUNTY_FIPS",
variable_name = "population"
)
# 5. View results
summary(result)
plot_transformation_perturbation(result)Must have columns: - zcta - 5-digit ZCTA code -
estimate (or your specified value column) - Numeric
value
Must have columns: - ZIP_CODE or zip - ZIP
code - zcta - ZCTA code
Must have columns: - ZIP - ZIP code -
COUNTY - County FIPS code - TOT_RATIO (or
other ratio) - Allocation ratio
The prep_* functions will validate your data and provide
helpful error messages if something is wrong.
vignette("hennepin-example") for a complete worked
examplevignette("conceptual_framework_shellgame", package = "shellgame")
for the conceptual explanationThese binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.