A redist_plans
object is essentially a data frame of summary
information on each district and each plan, along with the matrix of district
assignments and information about the simulation process used to generate the
plans.
redist_plans(plans, map, algorithm, wgt = NULL, ...)
a matrix with n_precinct
columns and n_sims
rows,
or a single vector of precinct assignments.
a redist_map
object
the algorithm used to generate the plans (usually "smc" or "mcmc")
the weights to use, if any.
Other named attributes to set
a new redist_plans
object.
The first two columns of the data frame will be draw
, a factor indexing
the simulation draw, and district
, an integer indexing the districts
within a plan. The data frame will therefore have n_sims*ndists
rows.
As a data frame, the usual dplyr
methods will work.
Other useful methods for redist_plans
objects:
data(iowa)
iowa <- redist_map(iowa, existing_plan = cd_2010, pop_tol = 0.05, total_pop = pop)
rsg_plan <- redist.rsg(iowa$adj, iowa$pop, ndists = 4, pop_tol = 0.05)$plan
#>
#> ====================
#> redist.rsg(): Automated Redistricting Starts
#>
#>
#> 4 districts built using 99 precincts in 0.06 seconds...
#>
redist_plans(rsg_plan, iowa, "rsg")
#> A <redist_plans> containing 1 sampled plan
#> Plans have 4 districts from a 99-unit map, and were drawn using random
#> seed-and-grow.
#> Plans matrix: int [1:99, 1] 4 4 1 3 4 3 1 2 1 1 ...
#> # A tibble: 4 × 3
#> draw district total_pop
#> * <fct> <int> <dbl>
#> 1 1 1 781611
#> 2 1 2 799275
#> 3 1 3 724719
#> 4 1 4 740750