library(MazamaSpatialUtils)
US_countyNameToFIPS("Washington", "King")
# If a single state is provided, it will be recycled
US_countyNameToFIPS("Washington", c("King", "Okanogan"))
# Normally, equal length vectors are provided
US_countyNameToFIPS(c("WA", "WA"), c("King", "Okanogan"))
# You cannot mix codes!
US_countyNameToFIPS(c("WA", "Washington"), c("King", "Okanogan"))
# No 'Okanogan' county in Texas
US_countyNameToFIPS(c("WA", "TX"), c("King", "Okanogan"))
# But there is a 'King' county in Texas
US_countyNameToFIPS(c("TX", "WA"), c("King", "Okanogan"))
US_countyNameToFIPS(c("TX", "WA"), c("King", "King"))
# The US_countyFIPSToName() function is included for symmetry but a
# more typical usage of a 5-digit county FIPS would be to extract it from
# the US_countyCodes package dataset:
US_countyCodes %>% dplyr::filter(countyFIPS == 53033)
Run the code above in your browser using DataLab