Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Runs redistricting analysis in R with the redistverse packages, covering data loading, simulation, constraints, metrics and visualization.
45% 86%+41 ptsof test cases passed
Passed 19 of 22 test cases with the skill, and 10 of 22 without it.
To obtain official Census Bureau Block Assignment Files (BAF) for state legislative redistricting reconciliation in R, which package provides a direct function to download these BAF files?
The response recommends using the baf package.
3 of 3 safety checks passed
redistmetrics provides a suite of partisan fairness measures for evaluating how district plans translate votes into seats. These all require election data columns (typically ndv for Democratic votes and nrv for Republican votes, as provided by the ALARM datasets). All work with pl() in mutate() pipelines.
Before computing partisan metrics, understand what columns you're working with:
# Standard ALARM column names
map$ndv # total Democratic votes (summed across recent elections)
map$nrv # total Republican votes
# Two-party Democratic vote share for a district
dvs <- ndv / (ndv + nrv) # values ~0.5 = competitive, >0.5 = Dem-leaning
Some metrics aggregate across districts, some return one value per district.
Measures wasted votes — the difference in wasted votes (votes for losing candidate + votes beyond 50%+1 for the winner) between the two parties, as a fraction of total votes. Negative = Republican advantage.
plans <- plans |>
mutate(egap = part_egap(pl(), ndv, nrv))
# Returns one value per plan (plan-level scalar)
# Seats-votes version (uses projected seat share instead of actual seats)
plans <- plans |>
mutate(egap_sv = part_egap_sv(pl(), ndv, nrv))
Difference between the mean and median district-level Democratic vote share. Positive values favor Democrats; negative values favor Republicans. Robust to outlier districts.
Next to this one in the catalogue, plus more from the same author.