Skip to contents

This function queries the USPS Crosswalks API provided by US Department of Housing and Urban Development (HUD USER). This returns the crosswalk for cbsadiv to zip.

Usage

hud_cw_cbsadiv_zip(
  cbsadiv,
  year = format(Sys.Date() - 365, "%Y"),
  quarter = 1,
  minimal = FALSE,
  key = Sys.getenv("HUD_KEY"),
  to_tibble = getOption("rhud_use_tibble", FALSE)
)

Arguments

cbsadiv

A character or numeric vector: 5 digit core based statistical area division code.

year

A character or numeric vector: gets the year that this data was recorded. Can specify multiple years. Default is the previous year.

quarter

A character or numeric vector: gets the quarter of the year that this data was recorded. Defaults to the first quarter of the year.

minimal

A logical: return just the crosswalked geoids if TRUE. Otherwise, return all fields. This does not remove duplicates.

key

A character vector of length one with the key obtained from HUD (US Department of Housing and Urban Development) USER website.

to_tibble

A logical: if TRUE, return the data in a tibble format rather than a data frame.

Value

This function returns a dataframe containing crosswalk data for cbsadiv to zip for all combinations of "cbsadiv", "year", and "quarter" inputs. These measurements include res-ratio, bus-ratio, oth-ratio, tot-ratio. For more details on these measurements, visit https://www.huduser.gov/portal/dataset/uspszip-api.html

Examples

if (FALSE) {

hud_cw_cbsadiv_zip(cbsadiv = 10380, year = c('2017'), quarter = c('4'))

hud_cw_cbsadiv_zip(cbsadiv = '10380', year = c('2017'), quarter = c('4'),
   minimal = TRUE)
}