Package 'baf'

Title: Block Assignment Files
Description: Download and read US Census Bureau data relationship files. Provides support for cleaning and using block assignment files since 2010, as described in <https://www.census.gov/geographies/reference-files/time-series/geo/block-assignment-files.html>. Also includes support for working with block equivalency files, used for years outside of decennial census years.
Authors: Christopher T. Kenny [aut, cre] , Cory McCartan [ctb]
Maintainer: Christopher T. Kenny <[email protected]>
License: MIT + file LICENSE
Version: 0.0.1
Built: 2024-11-09 02:51:45 UTC
Source: https://github.com/christopherkenny/baf

Help Index


Download Block Assignment Files (BAF) from the Census Bureau

Description

Download Block Assignment Files (BAF) from the Census Bureau

Usage

baf(
  state,
  year = 2020,
  geographies = NULL,
  cache_to = baf_download_path(),
  overwrite = FALSE
)

Arguments

state

state to download data for.

year

year to download data for. Default is 2020.

geographies

geography types to download. Default is NULL, which gets all available geographies.

cache_to

directory name to save the downloaded data. Default is baf_download_path().

overwrite

Should the data be re-downloaded? Default is FALSE.

Value

a list of tibbles for each geography type

Examples

baf('DE', 2020)

Download a file

Description

Download a file

Usage

baf_download(url, path, overwrite = FALSE, quiet = FALSE)

Arguments

url

a URL

path

a file path

overwrite

should the file at path be overwritten if it already exists? Default is FALSE.

quiet

should output and progress bar be suppressed?

Value

a path to the downloaded file, invisibly

Examples

tf <- tempfile(fileext = '.zip')
ex <- 'https://www2.census.gov/geo/docs/maps-data/data/baf2020/BlockAssign_ST01_AL.zip'
baf_download(url = ex, path = tf)

Get download location for baf files

Description

Get download location for baf files

Usage

baf_download_path()

Value

a path

Examples

baf_download_path()

Clean Block Assignment Files

Description

Clean Block Assignment Files

Usage

clean_bafs(bafs, state = NULL)

Arguments

bafs

list of block assignment files, named by type

state

if provided, adds the first two digits of the state FIPS to each code

Value

a tibble with two columns

  • GEOID: block GEOIDs

  • target: output GEOIDs for the target geography

Examples

baf('WA') |> clean_bafs('WA')