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
redist is the core simulation package. It creates redist_map objects that define the redistricting problem, runs SMC or MCMC algorithms to sample an ensemble of valid plans, and provides diagnostics to assess convergence. Start here for any simulation task.
redist_mapmap <- redist_map(shp, pop_col = 'pop', ndists = 8, adj = NULL,
pop_tol = 0.005, total_pop = NULL)
| Parameter | Description |
|---|---|
shp | sf object with one row per precinct |
pop_col | Column name for population (string) |
ndists | Number of districts to draw |
adj | Pre-built adj object; computed from shp if NULL |
pop_tol | Population deviation tolerance (0.005 = ±0.5%) |
# Typical setup
library(redistverse)
map <- alarm_50state_map('MD') # pre-built map with adj, pop, elections
map <- set_pop_tol(map, 0.005) # adjust tolerance after construction
get_pop_tol(map) # retrieve current tolerance
Subsetting: map[map$county == "Baltimore City", ] — redist_map subsets preserve the adj, ndists, and pop_tol metadata.
redist_smc() — Sequential Monte Carlo (recommended)Builds plans district-by-district by drawing random spanning trees and cutting edges. Most efficient for large ensembles; produces approximately independent draws.
plans <- redist_smc(
map,
Next to this one in the catalogue, plus more from the same author.