Skip to contents

redistio provides a point-and-click districting interface powered by Shiny and mapgl. For regular sf objects, it can be used to draw districts and export assignment files. For redist_map objects, algorithmic assistance is enabled for map drawing.

Installation

You can install the development version of redistio from GitHub with:

pak::pak('christopherkenny/redistio')

Or from R-universe with:

install.packages('redistio', repos = c('https://christopherkenny.r-universe.dev', 'https://cloud.r-project.org'))

Example

The most basic application of redistio starts with an sf tibble and a column of district assignments.

library(redistio)

draw(dc, dc$ward)

Configuration

Editor options

The editor can be configured primarily through redistio_options(). Some configurable options:

  • theme: the bslib theme to use
  • panels: which panels to include. Allows for removing panels like elections, if drawing districts in a party-blind manner
  • palette_party: the colors to use for partisan maps
  • palette_pop: the colors to use for population maps
  • palette_pct: the colors to use for percentage maps. Diverging palettes are recommended.
  • map_tiles: the base map style function to use from mapgl
  • use_alogrithms: whether to enable algorithmic assistance for map drawing. Requires a redist_map object.
  • alg_max_districts: the maximum number of districts allowed in algorithmic simulations
  • alg_max_sims: the maximum number of simulations allowed in algorithmic simulations
  • use_planscore: whether to use the PlanScore API to evaluate plans. Requires internet access and a PlanScore key.

Data Dependent Options

Several data-based options may be configured inside draw():

  • layers: Columns to use as toggle layers, where you can show things like county lines above the shapes
  • elect_cols: Specify election columns directly. This use a guessing approach which follows the ALARM Project column naming schema by default.
  • demog_cols: Specify demographic columns directly. This use a guessing approach which follows the ALARM Project column naming schema by default.
  • split_cols: Specify columns which contain administrative units to check splits for.
  • hover_fn: A function to display precinct-data based on the row of shp that the mouse is over.