Learn R Programming

redist (version 3.1.5)

flip_constraints_helper: Flip Constraints Helper

Description

Creates a constraints list for use with redist_flip.

Usage

flip_constraints_helper(
  map,
  constraint = "compact",
  constraintweight = 0.6,
  init_plan = NULL,
  compactness_metric = "edges-removed",
  areas,
  borderlength_mat,
  ssdmat,
  ssd_denom,
  counties = NULL,
  partisan_metric = "efficiency-gap",
  rvote,
  dvote,
  group_pop = NULL,
  target_min = 0.55,
  target_other = 0.25,
  minorityprop
)

Arguments

map

A redist_map object.

constraint

character vector of constraints to use. Current accepted are "compact", "population", "countysplit", "hinge", "vra", "minority", "similarity", "partisan", and "segregation." Defaults to compact.

constraintweight

corresponding weights to use with constraint. Weights must be nonzero if provided. Defaults to a weak compactness constraint

init_plan

initial plan to use for the similarity constraint

compactness_metric

character with "edges-removed", "polsby-popper", or "fryer-holden". Default is edges-removed.

areas

areas to use with compact:polsby-popper. Computed from map if not provided and needed.

borderlength_mat

border lengths to use with compact:polsby-popper. Computed from map if not provided and needed.

ssdmat

squared distance matrix to use with compact:fryer-holden. Computed from map if not provided and needed.

ssd_denom

Denominator for compact:fryer-holden. Defaults to 1.0

counties

tidy evaluated column with counties in map.

partisan_metric

character with "proportional-representation" or "efficiency-gap"

rvote

numeric vector of votes for Republicans. used with partisan constraint.

dvote

numeric vector of votes for Democrats used with partisan constraint.

group_pop

tidy evaluated column with group populations in map. Used with hinge, segregation, vra, and minority.

target_min

numeric with higher minority target for vra. Defaults to 0.55.

target_other

numeric with higher minority target for vra. Defaults to 0.25.

minorityprop

minority proportions to target. Used by minority and hinge.Defaults to c(0.55) if none specified.

Value

list with an entry for each constraint usable with redist_flip()

Examples

Run this code
# NOT RUN {
data(iowa)
iowa_map <- redist_map(iowa, existing_plan = cd_2010, total_pop = pop, pop_tol = 0.01)
cons <- flip_constraints_helper(
  map = iowa_map, constraint = c('compact', 'vra'),
  constraintweight = c(0.05, 10), target_min = 0.05,
  target_other = 0.01, group_pop = black
)

redist_flip(iowa_map, 10, constraints = cons)

# }

Run the code above in your browser using DataLab