Learn R Programming

redist (version 3.0.7)

match_numbers: Renumber districts to match an existing plan

Description

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.

Usage

match_numbers(data, plan, col = "pop_overlap", force = FALSE)

Arguments

data

a redist_plans object

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.

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 NULL if no column should be created.

force

if TRUE, force computation when there are more than 1,000 renumbering options in any plan.

Value

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.