match_numbers | R Documentation |
District numbers in simulated plans are by and large random. This function attempts to renumber the districts across all simulated plans to match the numbers in a provided plan, using the Hungarian algorithm.
match_numbers(
data,
plan,
total_pop = attr(data, "prec_pop"),
col = "pop_overlap"
)
data |
a |
plan |
a character vector giving the name of the plan to match to (e.g., for a reference plan), or an integer vector containing the plan itself. |
total_pop |
a vector of population counts. Should not be needed for most
|
col |
the name of a new column to store the vector of population overlap
with the reference plan: the fraction of the total population who are in
the same district under each plan and the reference plan. Set to
|
a modified redist_plans
object. New district numbers will be
stored as an ordered factor variable in the district
column. The
district numbers in the plan matrix will match the levels of this factor.
data(iowa)
iowa_map <- redist_map(iowa, existing_plan = cd_2010, pop_tol = 0.05)
plans <- redist_smc(iowa_map, 100, silent = TRUE)
match_numbers(plans, "cd_2010")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.