Package 'redistio'

Title: Interactive Redistricting
Description: A point and click editor for districts built on 'shiny' and 'Leaflet'. Users can draw districts and calculate standard redistricting metrics, like compactness or the number of administrative splits. Maps can be exported as assignment files or shapefiles, readable by most other redistricting software.
Authors: Christopher T. Kenny [aut, cre] , Cory McCartan [aut] , leaflet contributors [cph] (setShapeStyle code adapted from leaflet package.)
Maintainer: Christopher T. Kenny <[email protected]>
License: GPL (>= 3)
Version: 0.0.0.9000
Built: 2024-09-27 02:44:24 UTC
Source: https://github.com/christopherkenny/redistio

Help Index


District of Columbia Geographic Data

Description

This file contains demographic, partisan, and geographic data for DC at the voting district level.

Format

sf object

GEOID20

US Census Geographic Identifier

state

state abbreviation

county

county name

vtd

voting district identifier

pop

total population

pop_hisp

Hispanic population

pop_white

White, non-Hispanic population

pop_black

Black, non-Hispanic population

pop_aian

American Indian and Alaskan Native, non-Hispanic population

pop_asian

Asian, non-Hispanic population

pop_nhpi

Native Hawaiian and Pacific Islander, non-Hispanic population

pop_other

Other, non-Hispanic population

pop_two

Two or More Races, non-Hispanic population

vap

voting age population

vap_hisp

Hispanic voting age population

vap_white

White, non-Hispanic voting age population

vap_black

Black, non-Hispanic voting age population

vap_aian

American Indian and Alaskan Native, non-Hispanic voting age population

vap_asian

Asian, non-Hispanic voting age population

vap_nhpi

Native Hawaiian and Pacific Islander, non-Hispanic voting age population

vap_other

Other, non-Hispanic voting age population

vap_two

Two or More Races, non-Hispanic voting age population

pre_16_dem_cli

votes for Clinton 2016, President (D)

pre_16_rep_tru

votes for Trump 2016, President (R)

uss_18_dem_bro

votes for Brown 2018, Shadow Senate (D)

atg_18_dem_rac

votes for Karl Racine, Attorney General (D)

pre_20_dem_bid

votes for Biden 2020, President (D)

pre_20_rep_tru

votes for Trump 2020, President (R)

uss_20_dem_str

votes for Strauss 2020, Shadow Senate (D)

uss_20_rep_wei

votes for Weiss 2020, Shadow Senate (R)

arv_16

average Republican vote in 2016

adv_16

average Democratic vote in 2016

arv_18

average Republican vote in 2018

adv_18

average Democratic vote in 2016

arv_20

average Republican vote in 2020

adv_20

average Democratic vote in 2016

nrv

normal Republican vote

ndv

normal Democratic vote

geometry

sf geometry

adv_nbr

Advisory Neighborhood names estimated to VTDs

ward

2022 ward lines estimated to VTDs

Examples

data(dc)

Interactive Plan Drawing

Description

Interactive Plan Drawing

Usage

draw(
  shp,
  init_plan,
  ndists,
  palette,
  layers = NULL,
  pop_tol = 0.05,
  pop_col = "pop",
  adj_col = "adj",
  split_cols = guess_admins,
  elect_cols = guess_elections,
  demog_cols = guesstimate_demographics,
  hover_fn = hover_precinct,
  opts = redistio_options()
)

Arguments

shp

an sf tibble that you want to draw with

init_plan

Plan to initialize with.

ndists

Number of districts to draw if init_plan is not supplied.

palette

Color palette to fill shapes with. Default is ⁠Polychrome 36⁠ or, if installed, crayons::crayons$no_48.

layers

Named list of sf objects to overlay. Also takes column names in shp to group by.

pop_tol

the population tolerance.

pop_col

Name of column in shp that contains population data.

adj_col

Name of column in shp that contains adjacency information.

split_cols

Names of column in shp that contain administrative units

elect_cols

Names of column in shp that contain election data

demog_cols

Names of column in shp that contain demographic data

hover_fn

Function to generate tables for mouse hovering. Default is hover_precinct().

opts

list of options. Default is redistio_options()

Value

Shiny app

Examples

if (interactive()) {
  draw(dc, dc$ward)
  draw(dc, dc$ward, layers = list(neighborhoods = 'adv_nbr'))
}

Guess which columns contain administrative units

Description

Guess which columns contain administrative units

Usage

guess_admins(shp)

Arguments

shp

an sf tibble that you want to draw with

Value

a named list of types

Examples

guess_admins(dc)

Guess which columns contain election data

Description

Guess which columns contain election data

Usage

guess_elections(shp)

Arguments

shp

an sf tibble that you want to draw with

Value

a named list of columns

Examples

guess_elections(dc)

Guess and estimate which columns contain demographic data

Description

Guess and estimate which columns contain demographic data

Usage

guesstimate_demographics(shp)

Arguments

shp

an sf tibble that you want to draw with

Value

a named list of columns

Examples

guesstimate_demographics(dc)

Create a tibble of precinct stats

Description

Create a tibble of precinct stats

Usage

hover_precinct(shp, ...)

Arguments

shp

a tibble::tibble with precinct stats

...

named tidyselections

Value

A tibble::tibble

Examples

hover_precinct(dc, 1, pop = dplyr::starts_with('pop'), vap = dplyr::starts_with('vap'))

Set options for redistio

Description

Set options for redistio

Usage

redistio_options(
  theme = "flatly",
  panels = c("elections", "demographics", "integrity", "algorithms"),
  select_color = "purple",
  palette_pop = "Purples",
  palette_pct = "PuOr",
  palette_party = ggredist::ggredist$partisan,
  map_tiles = "CartoDB.Positron",
  leaflet_height = "91vh",
  crs = 4326,
  na_color = "#0000",
  layer_weight = 1.5,
  layer_color = "#000000",
  locked_districts = NULL,
  use_algorithms = TRUE,
  alg_max_districts = 3,
  alg_max_sims = 100,
  use_planscore = TRUE,
  save_assignment_path = "redistio.csv",
  save_shape_path = "redistio.geojson",
  ...
)

Arguments

theme

a name of a bootswatch preset theme or other bslib::bs_theme() object

panels

which panels to display in the app, 'draw' is always shown.

select_color

a color to use for highlighting selected districts

palette_pop

a color palette to use for whole people

palette_pct

a color palette to use for percentages of people

palette_party

a color palette to use for parties

map_tiles

a tileset to use for the map background, from leaflet::providers

leaflet_height

height to pass to leaflet::leafletOutput()

crs

a coordinate reference system to use in leaflet::leaflet()

na_color

a color to use for unassigned precincts

layer_weight

a stroke width to use for layers in leaflet::leaflet()

layer_color

colors to use for layers in leaflet::leaflet()

locked_districts

districts to lock on app start to stop edits

use_algorithms

whether to use redistricting simulation algorithms

alg_max_districts

maximum number of districts to use in algorithms

alg_max_sims

maximum number of simulations to use in algorithms

use_planscore

whether to use PlanScore to evaluate plans

save_assignment_path

Output path to save assignment file to.

save_shape_path

Output path to save shapefile to.

...

additional arguments (currently ignored)

Value

a list

Examples

redistio_options()