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
ggredist extends ggplot2 with geoms, scales, and themes designed specifically for redistricting maps and election data. The key innovation is geom_district(), which dissolves precinct polygons into district regions and handles adjacent-district coloring automatically.
geom_district()Dissolves precinct-level sf geometries into district polygons and fills them by a variable. The group aesthetic specifies the district assignment column.
library(ggredist)
library(ggplot2)
# Basic district map — color by district number
ggplot(map, aes(fill = cd_2020, group = cd_2020)) +
geom_district() +
theme_map()
# Partisan vote share (fill + denom computes the ratio automatically)
ggplot(map, aes(fill = ndv, group = cd_2020, denom = ndv + nrv)) +
geom_district() +
scale_fill_party_c() +
theme_map()
| Aesthetic | Description |
|---|---|
group | District assignment column (required) |
fill | Numerator for fill; if denom is provided, computes fill/denom |
denom | Denominator for ratio fill (optional) |
color | Border color (default: black) |
linewidth | Border width (default: 0.3) |
ggredist uses adj_color() from the adj package to automatically assign colors so adjacent districts differ. Pass color_adj = TRUE (or use the adj from the map):
Next to this one in the catalogue, plus more from the same author.