This function queries the USPS Crosswalks API provided by US Department of Housing and Urban Development (HUD USER). This returns the crosswalk for countysub to zip.
Usage
hud_cw_countysub_zip(
countysub,
year = format(Sys.Date() - 365, "%Y"),
quarter = 1,
minimal = FALSE,
key = Sys.getenv("HUD_KEY"),
to_tibble = getOption("rhud_use_tibble", FALSE)
)
Arguments
- countysub
A character or numeric vector: 10 digit county sub 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
If TRUE, return the data in a tibble format rather than a data frame.
- tract
A character or numeric vector: 11 digit tract code.
Value
This function returns a dataframe containing crosswalk data for countysub to zip for all combinations of "countysub", "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_countysub_zip(countysub = '4606720300',
year = c('2019', '2019', '2019'), quarter = c('4','4'))
hud_cw_countysub_zip(countysub = '3706794068',
year = c('2019', '2019', '2019'), quarter = c('4','4'))
hud_cw_countysub_zip(countysub = '3711993268',
year = c('2019', '2019', '2019'), quarter = c('4','4'))
hud_cw_countysub_zip(countysub = '3910383426',
year = c('2019'), quarter = c('1'), minimal = TRUE)
}