Tallies the number of unique sub-administrative unit-districts. An unsplit administrative unit will return an entry of 1, while each additional sub-administrative unit-district adds 1.

splits_sub_count(plans, shp, sub_admin)

Arguments

plans

A redist_plans object or plans_matrix where each row indicates a district assignment and each column is a plan.

shp

A redist_map object, tibble, or data frame containing other columns.

sub_admin

Unqouted name of column in shp with numeric identifiers for subsidiary administrative units.

Value

numeric matrix

Examples

data(nh)
data(nh_m)
# For a single plan:
splits_sub_count(plans = nh$r_2020, shp = nh, sub_admin = county)
#>                     [,1]
#> Belknap County         1
#> Carroll County         2
#> Cheshire County        1
#> Coos County            1
#> Grafton County         2
#> Hillsborough County    2
#> Merrimack County       2
#> Rockingham County      2
#> Strafford County       2
#> Sullivan County        1

# Or many plans:
splits_sub_count(plans = nh_m[, 3:5], shp = nh, sub_admin = county)
#>                     [,1] [,2] [,3]
#> Belknap County         1    1    2
#> Carroll County         1    1    1
#> Cheshire County        2    1    1
#> Coos County            1    1    1
#> Grafton County         1    2    1
#> Hillsborough County    2    2    2
#> Merrimack County       2    2    2
#> Rockingham County      2    2    2
#> Strafford County       1    1    2
#> Sullivan County        1    1    1