Learn R Programming

redist (version 4.0.1)

redist.plot.distr_qtys: Plot quantities by district

Description

Plots a boxplot of a quantity of interest across districts, with districts optionally sorted by this quantity. Adds reference points for each reference plan, if applicable.

Usage

redist.plot.distr_qtys(
  plans,
  qty,
  sort = "asc",
  geom = "jitter",
  color_thresh = NULL,
  size = 0.1,
  ...
)

Value

A ggplot

Arguments

plans

the redist_plans object.

qty

<data-masking> the quantity of interest.

sort

set to "asc" to sort districts in ascending order of qty (the default), "desc" for descending order, or FALSE or "none" for no sorting.

geom

the geom to use in plotting the simulated districts: either "jitter" or "boxplot"

color_thresh

if a number, the threshold to use in coloring the points. Plans with quantities of interest above the threshold will be colored differently than plans below the threshold.

size

The dot size for geom="jitter".

...

passed on to geom_boxplot

Examples

Run this code
library(dplyr)
data(iowa)

iowa <- redist_map(iowa, existing_plan = cd_2010, pop_tol = 0.05, total_pop = pop)
plans <- redist_smc(iowa, nsims = 100, silent = TRUE)
plans %>%
    mutate(pct_dem = group_frac(iowa, dem_08, tot_08)) %>%
    redist.plot.distr_qtys(pct_dem)

Run the code above in your browser using DataLab