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
adj is an S3 vector class representing precinct adjacency graphs. Each element is a zero-indexed integer vector of neighbors. The adjacency graph is stored as the adj column of a redist_map, and is central to all tree-based simulation algorithms. Use adj functions when you need to construct, inspect, or modify the adjacency structure.
The most common approach: compute adjacency from shared boundaries in an sf object.
library(adj)
# Build adjacency from shared polygon boundaries
adjacency <- adj_from_shp(shp) # sf object with polygon geometry
# Equivalent using the map directly
adjacency <- adj_from_shp(map)
The alarm_50state_map() function returns a redist_map with the adj column pre-built:
map <- alarm_50state_map('MD')
adj_graph <- map$adj # already computed
# Create from a list of neighbor index vectors (zero-indexed)
adj_graph <- adj(list(
c(1L, 2L), # precinct 0 is adjacent to precincts 1 and 2
c(0L, 2L), # precinct 1 is adjacent to 0 and 2
c(0L, 1L) # precinct 2 is adjacent to 0 and 1
))
Next to this one in the catalogue, plus more from the same author.