Package 'cvap'

Title: Citizen Voting Age Population
Description: Works with the Citizen Voting Age Population special tabulation from the US Census Bureau <https://www.census.gov/programs-surveys/decennial-census/about/voting-rights/cvap.html>. Provides tools to download and process raw data. Also provides a downloading interface to processed data. Implements a very basic approach to estimate block level citizen voting age population from block group data.
Authors: Christopher T. Kenny [aut, cre]
Maintainer: Christopher T. Kenny <[email protected]>
License: MIT + file LICENSE
Version: 0.1.5
Built: 2024-08-19 04:32:28 UTC
Source: https://github.com/christopherkenny/cvap

Help Index


Get Zip File URL for CVAP Special Tabulation Data

Description

Get Zip File URL for CVAP Special Tabulation Data

Usage

cvap_census_url(year = 2022)

Arguments

year

numeric. Year for the data in 2009 to 2022.

Value

string

Examples

cvap_census_url()

Estimate CVAP at the Block Level

Description

Assuming citizenship homogeneity within block group race/ethnicity, estimates down from block groups to the block level, proportionally by group if possible, otherwise by total population.

Usage

cvap_distribute(cvap, block, wts = "pop", include_implied = TRUE)

Arguments

cvap

cvap data at the block group level, using default settings of get_cvap()

block

block data data for the Census before (or the same as) the year of the cvap data

wts

'pop' (default) or 'vap' for the group to distribute by.

include_implied

logical if a column for the implied total (impl_cvap) should be included. Default is TRUE

Value

cvap tibble estimated at the block level

Examples

## Not run: 
# Requires API set up with tidycensus
state <- 'DE'
cvap <- cvap_get(state, year = 2019)
de_block <- censable::build_dec(geography = 'block',
state = state, year = 2010, geometry = FALSE)

## End(Not run)
# Alternatively, using example data
state <- 'DE'
cvap <- cvap_get(state, year = 2019)
data('de_block')
cvap_block <- cvap_distribute(cvap, de_block)

Distribute CVAP at the Block Group and Download Data

Description

Downloads CVAP, block data, and block group data all together. Calls cvap_distribute within.

Usage

cvap_distribute_censable(
  state,
  year = 2022,
  clean = TRUE,
  wts = "pop",
  include_implied = TRUE
)

Arguments

state

character. The state to get data for or nation for the nation file.

year

numeric. Year for the data in 2009 to 2022.

clean

Should variable names be standardized? Default is TRUE.

wts

'pop' (default) or 'vap' for the group to distribute by.

include_implied

logical if a column for the implied total (impl_cvap) should be included. Default is TRUE

Value

cvap tibble estimated at the block level

Examples

## Not run: 
# Requires API set up with tidycensus or censable
cvap_distribute_censable('DE', 2019)

## End(Not run)

Download Processed Citizen Voting Age Population Data

Description

Downloads processed CVAP data for a state. CVAP data is rounded to the nearest 5 so totals may not sum properly, but will be close.

Usage

cvap_get(
  state,
  year = 2022,
  geography = "block group",
  out_file = NULL,
  moe = FALSE,
  clean = TRUE
)

Arguments

state

character. The state to get data for or nation for the nation file.

year

numeric. Year for the data in 2009 to 2022.

geography

character. Level of geography. Default is 'block group'. See Details.

out_file

file to save downloaded rds to

moe

Include margin of error? Default is FALSE.

clean

Should variable names be standardized? Default is TRUE.

Details

Geography options are

  • 'block group': block group level data

  • 'cd': congressional district data (years 2016+)

  • 'county': county-level data

  • 'place': place-level data

  • shd': state house district data (years 2016+)

  • 'ssd': state senate district data (years 2016+)

  • 'state': state-level data

  • 'tract': tract-level data

  • 'nation': nation-wide data

Value

tibble of data

Examples

cvap_get('DE')

Get Raw Citizen Voting Age Population Files

Description

Get Raw Citizen Voting Age Population Files

Usage

cvap_get_raw(url, out_dir)

Arguments

url

URL to CVAP zip to download. Use cvap_census_url().

out_dir

Directory to unzip to. Defaults to temp directory.

Value

string, path where the data is saved

Examples

# takes 10-20 seconds
path <- cvap_get_raw(cvap_census_url())

Process Directory of CVAP Files

Description

Process Directory of CVAP Files

Usage

cvap_process_dir(dir, year, out_dir, moe = TRUE, csv = FALSE)

Arguments

dir

Path to directory with the CVAP files

year

file year

out_dir

directory to create files in

moe

Boolean. Default is TRUE. Should margin of error be kept?

csv

Boolean. Default is FALSE, which creates an rds file instead.

Value

list of tibbles of cvap

Examples

path <- fs::path_package('cvap', 'extdata')
cvap_process_dir(path, year = 2019, out_dir = tempdir())

Process Census CVAP File

Description

Process Census CVAP File

Usage

cvap_process_file(path, year, out_dir, moe = TRUE, csv = FALSE)

Arguments

path

path to csv file

year

file year

out_dir

directory to create files in

moe

Boolean. Default is TRUE. Should margin of error be kept?

csv

Boolean. Default is FALSE, which creates an rds file instead.

Value

tibble of cvap data

Examples

path <- fs::path_package('cvap', 'extdata', 'County.csv')
cvap_process_file(path, year = 2019, out_dir = tempdir())

Delaware Block Example Data

Description

This data set contains block level data for Delaware for 2010.

Usage

data("de_block")

Format

A tibble with population data for Delaware blocks from Census 2010

Examples

data(de_block)

Delaware Block Group Example Data

Description

This data set contains block group level data for Delaware for 2019 from the American Community Survey. This is the five year variant (2015-2019).

Usage

data("de_block_group")

Format

A tibble with population data for Delaware blocks groups from ACS 2019

Examples

data(de_block_group)

Download Processed VEST Block Crosswalk

Description

Provides a friendlier data format for R for working with VEST crosswalks. Data can be retallied with PL94171::pl_retally() using this crosswalk.

Usage

vest_crosswalk(state)

Arguments

state

character. The state to get the VEST crosswalk for.

Value

tibble

References

Amos, Brian, 2021, "2020 Census Block Crosswalk Data", https://doi.org/10.7910/DVN/T9VMJO, Harvard Dataverse, V2

Examples

de_cw <- vest_crosswalk('DE')