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 zip to cd.

Usage

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

Arguments

zip

A character or numeric vector: 5 digit (United States Postal Service) USPS zipcode of the data to retrieve. E.g. 22031 for type 1 to 5 and 11 .

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 zip to cd for all combinations of "zip", "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_zip_cd(zip = '35213', year = c('2010'), quarter = c('1'))

hud_cw_zip_cd(zip = '35213', year = c('2010'), quarter = c('1'),
   minimal = TRUE)
}