Title: | Crosswalk Between 2020 Census ZIP Code Tabulation Areas (ZCTAs), States and Counties |
---|---|
Description: | Contains the US Census Bureau's 2020 ZCTA to County Relationship File, as well as convenience functions to translate between States, Counties and ZIP Code Tabulation Areas (ZCTAs). |
Authors: | Ari Lamstein [aut, cre], MarketBridge LLC [cph, fnd] |
Maintainer: | Ari Lamstein <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0.0 |
Built: | 2024-11-12 05:12:08 UTC |
Source: | https://github.com/marketbridge/zctacrosswalk |
Returns the Census Bureau's 2020 ZCTA Country Relationship file as a tibble. This function is included so that users can see how the crosswalk was generated. It is not intended for use by end users.
get_zcta_crosswalk()
get_zcta_crosswalk()
A tibble, where each row is a (zcta, county, state) combination.
All 2020 ZIP Code Tabulation Area 5-Digit (ZCTA5) Relationship Files: https://rb.gy/h0l5cs
Given a vector of ZIP Code Tabulation Areas (ZCTAs), return what state and county they are in. NOTE: A single ZCTA can span multiple states and counties.
get_zcta_metadata(zctas)
get_zcta_metadata(zctas)
zctas |
A vector of ZCTAs (character or numeric) |
A tibble, where each row is a (zcta, county, state) combination.
get_zcta_metadata("90210") # Some ZCTAs span multiple counties get_zcta_metadata(39573)
get_zcta_metadata("90210") # Some ZCTAs span multiple counties get_zcta_metadata(39573)
Given a vector of counties, return the ZIP Code Tabulation Areas (ZCTAs) in those counties. Note counties must be identified by FIPS code (character or numeric) in this function because county names are not unique between states. For example, 30 states have a county named "Washington".
get_zctas_by_county(counties)
get_zctas_by_county(counties)
counties |
A vector of Counties. Must be by FIPS code (numeric or character). |
A vector, where each element is a ZCTA in the requested county.
# "06075" is San Francisco County, California get_zctas_by_county("06075") # 6075 (== as.numeric("06075")) works too get_zctas_by_county(6075) # Multiple counties at the same time are also OK get_zctas_by_county(c("06075", "36059"))
# "06075" is San Francisco County, California get_zctas_by_county("06075") # 6075 (== as.numeric("06075")) works too get_zctas_by_county(6075) # Multiple counties at the same time are also OK get_zctas_by_county(c("06075", "36059"))
Given a vector of states, return the ZIP Code Tabulation Areas (ZCTAs) in those states.
get_zctas_by_state(states)
get_zctas_by_state(states)
states |
A vector of States. Can be FIPS Codes (either character or numeric), names or USPS abbreviations. |
A vector, where each element is a ZCTA in the requested state.
# Not case sensitive when using state names ca_zctas = get_zctas_by_state("CaLiFoRNia") length(ca_zctas) head(ca_zctas) # "06" is the FIPS code for California ca_zctas = get_zctas_by_state("06") length(ca_zctas) head(ca_zctas) # 6 is OK too - sometimes people use numbers for FIPS codes ca_zctas = get_zctas_by_state(6) length(ca_zctas) head(ca_zctas) # USPS state abbreviations are also OK ca_zctas = get_zctas_by_state("CA") length(ca_zctas) head(ca_zctas) # Multiple states at the same time are also OK ca_ny_zctas = get_zctas_by_state(c("CA", "NY")) length(ca_ny_zctas) head(ca_ny_zctas)
# Not case sensitive when using state names ca_zctas = get_zctas_by_state("CaLiFoRNia") length(ca_zctas) head(ca_zctas) # "06" is the FIPS code for California ca_zctas = get_zctas_by_state("06") length(ca_zctas) head(ca_zctas) # 6 is OK too - sometimes people use numbers for FIPS codes ca_zctas = get_zctas_by_state(6) length(ca_zctas) head(ca_zctas) # USPS state abbreviations are also OK ca_zctas = get_zctas_by_state("CA") length(ca_zctas) head(ca_zctas) # Multiple states at the same time are also OK ca_ny_zctas = get_zctas_by_state(c("CA", "NY")) length(ca_ny_zctas) head(ca_ny_zctas)
The complete dataset in ?zcta_crosswalk contains information on 56 state and state-equivalents. This dataframe contains the full name of each "state", plus its USPS abbreviation and FIPS code.
data(state_names)
data(state_names)
The primary data was obtained via the function get_zcta_crosswalk. There are 3 types of columns: ZCTA, state and county. Where data in practice sometimes appears as both character and numeric, columns for both are provided.
data(zcta_crosswalk)
data(zcta_crosswalk)