baf_to_vtd: Estimate Plans from a Block Assignment File to Voting...

View source: R/baf_to_vtd.R

baf_to_vtdR Documentation

Estimate Plans from a Block Assignment File to Voting Districts

Description

District lines are often provided at the census block level, but analyses often occur at the voting district level. This provides a simple way to estimate the block level to the voting district level.

Usage

baf_to_vtd(baf, plan_name, GEOID = "GEOID")

Arguments

baf

a tibble representing a block assignment file.

plan_name

character. Name of column in baf which corresponds to the districts.

GEOID

character. Name of column which corresponds to each block's GEOID, sometimes called "BLOCKID". Default is 'GEOID'.

Details

If a voting district is split between blocks, this currently uses the most common district.

Value

a tibble with a vtd-level assignment file

Examples

# Not guaranteed to reach download from redistrict2020.org
## Not run: 
# download and read baf ----
url <- 'https://www.redistrict2020.org/files/DE-2021-01/DE_SLDU_bef.zip'
tf <- tempfile('.zip')
utils::download.file(url, tf)
utils::unzip(tf, exdir = dirname(tf))
baf <- readr::read_csv(
  file = paste0(dirname(tf), '/DE_SLDU_bef.csv'),
  col_types = 'ci'
)
names(baf) <- c('GEOID', 'ssd_20')

# convert to vtd level ----
baf_to_vtd(baf = baf, plan_name = 'ssd_20', 'GEOID')

## End(Not run)


geomander documentation built on April 16, 2023, 5:18 p.m.