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
geomander provides the primary tools for building, inspecting, and repairing precinct adjacency graphs in redistricting. This file covers adjacency construction, contiguity checking, edge editing, and the seam tools for removing edges along administrative boundaries. See also 10-geomander-spatial.md for spatial estimation and 11-geomander-data.md for data downloads.
library(geomander)
# Build from an sf shapefile (returns a zero-indexed list of neighbor vectors)
adj <- adjacency(shp = precincts_sf)
# Store in a redist_map
map <- redist_map(precincts_sf, pop_col = 'pop', ndists = 8, adj = adj)
Note: The adj package's adj_from_shp() provides a similar function with a validated S3 class. The geomander::adjacency() output is a plain list — compatible with redist which accepts either.
After building or modifying an adjacency graph, always verify connectivity within each group (e.g., each county or district):
# Full contiguity report — returns tibble with group, group_number, component
check_contiguity(adj = adj, group = map$county)
# component == 1 for all rows = fully connected within each county
# component > 1 indicates disconnected islands
# Aliases:
cct(adj, group) # frequency table of component counts (1 = all contiguous)
ccm(adj, group) # max component number (1 = all contiguous)
# Check overall graph (no groups — are all precincts reachable?)
check_contiguity(adj = adj) # group defaults to 1 (single group)
# Check polygon contiguity (geometry-based, no adj needed)
check_polygon_contiguity(shp = precincts_sf, group = precincts_sf$county)
Next to this one in the catalogue, plus more from the same author.