# Measures of Administrative Splits

This vignette introduces some of the most common measures of administrative splits. These functions are designed around common concerns generalized to keeping together “political subdivisions”. See the vignette “Using `redistmetrics`” for the bare-bones of the package.

We first load the `redistmetrics` package and data from New Hampshire. For any function, the `shp` argument can be swapped out for your data, `county` for your administrative unit, and the `plans` argument can be swapped out for your redistricting plans (be it a single plan, a matrix of plans, or a `redist_plans` object).

    library(redistmetrics)
    data(nh)

## Administrative Splits

The most typical thing to check in a redistricting plan is how many counties are split by a plan. The units need not be counties, but are typically some form of administrative unit. (This is often of interest because, theoretically, each redistricting plan need only split one less county than it has districts.)

Every unit needs to be assigned to an administrative unit.

The number of administrative splits can be computed with:

    splits_admin(plans = nh$r_2020, shp = nh, admin = county)
    #> [1] 6 6

## Sub-Administrative Splits

Secondarily, we are often interested in how many municipalities are split by a plan. These units are smaller and may not cover the entire state. Units which are not assigned to a sub-administrative unit should be assigned `NA`.

The number of sub-administrative splits can be computed with:

    splits_sub_admin(plans = nh$r_2020, shp = nh, sub_admin = county)
    #> [1] 6 6

(Often you would not check `county` here, but instead some unit smaller than a county.)

## Mutli-Splits

Beyond knowing how many administrative units are split, we may want to know how many are split more than once. We define splitting a unit more than once as a “multi-split”.

Every unit needs to be assigned to an administrative unit.

The number of multi-splits can be computed with:

    splits_multi(plans = nh$r_2020, shp = nh, admin = county)
    #> [1] 0 0

## Counting Splits

Finally, if a state has a special condition, you may be interested in how many times a particular administrative unit is split. We count here the number of districts that appear within an administrative unit. Unlike most other functions, this returns a matrix, where rows are counties and columns are plans.

The number of splits for each county can be computed with:

    splits_count(plans = nh$r_2020, shp = nh, admin = county)
    #>       [,1]
    #>  [1,]    1
    #>  [2,]    2
    #>  [3,]    1
    #>  [4,]    1
    #>  [5,]    2
    #>  [6,]    2
    #>  [7,]    2
    #>  [8,]    2
    #>  [9,]    2
    #> [10,]    1