Fixing defunct US county codes - sparklabnyc/resources GitHub Wiki
US counties are regularly updated. Counties that existed at the beginning of the dataset may no longer exist.
To find the counties, compare the list of FIPS codes to the list in the most recent year of the data.
old_fips <- c()
fips_final <- fips_list |> pluck("2021")
for (y in years) {
print(y)
codes <- fips_list |> pluck(str_c(y))
difference <- setdiff(codes, fips_final)
old_fips <- c(old_fips, difference)
}
# all the fips that aren't in 2021 (final year)
old_fips <- sort(unique(old_fips))
> old_fips
[1] "02010" "02140" "02201" "02231" "02232" "02280" "05000" "12025" "13999"
[10] "15005" "30113" "38000" "48269" "51515" "51560" "51780" "53000"
Then manually fix map these counties to a new county.
# Perform the mapping of old boundaries to the most recent county boundaries
# Alaska: https://www.cdc.gov/nchs/data/nvss/bridged_race/County-Geography-Changes-1990-present.pdf
# Alaska: https://www.cdc.gov/nchs/data/mortab/1999-2010CMFDocumentation.pdf
# https://www.ddorn.net/data/FIPS_County_Code_Changes.pdf
# Following IHME https://cdn.jamanetwork.com/ama/content_public/journal/intemed/936342/ioi170020supp1_prod.pdf?Expires=1709591019&Signature=sy0JSwUE0k4QMaE2D5wUui9DSJSBbRQ~0piRLTsvTDT8PQtyRZGTgK4cKeNGdj4eKomCaa6HeAIawHe6blNQySejzHZQts-zU8kZq6oQ4NtyrhkF1Dpx6FHAVC3QSixyao~nwQrru6rN4dSnKkQWJJb1uVagGqJ8Cxim6Vc1l912YpzPsy2lCHTCssWBvVfGXEVjfeankr29i3Gacr2ISmxXkZDwTLybFd2Go8PP4srMI42NHKHSw-~w2zqWMLWUrnPTFklstvEoWe7znL-UjwKW5EPmPCXtul8kyH1cuOm6~F0dmu~YYBoKVoFJp~yfORcuoolhIg~CzsVZT8Td5w__&Key-Pair-Id=APKAIE5G5CRDK6RD3PGA
# Inequalities in Life Expectancy Among US Counties, 1980 to 2014
# eTable 1: Counties combined to ensure historically stable units of analysis
# be aware that the supercounties have existing county codes and shapefiles will need to be combined
data <- data |>
mutate(
fips = case_when(
# Alaska
fips == "02270" ~ "02158", # 1. Kusilvak Census Area = Kusilvak Census Area + Wade Hampton Census Area (renamed)
fips == "02140" ~ "02188", # 2. Nortwest Arctic Borough = Nortwest Arctic Borough + Kobuck (renamed)
fips == "02010" ~ "02013", # 3. Aleutians East Borough = Aleutians East Borough + Aleutian Islands Census Area +
fips == "02016" ~ "02013", # Aleutians West Census Area (two created from Aleutian Islands Census Area)
fips == "02068" ~ "02164", # 4. Lake and Peninsula Borough = Dillingham Census Area + Lake and Peninsula Borough
fips == "02068" ~ "02290", # 5. Yukon-Koyukuk Census Area = Yukon-Koyukuk Census Area + Denali Borough
fips == "02105" ~ "02282", # 6. Yakutat City and Borough = Yakutat City and Borough + Hoonah-Angoon Census Area
fips == "02230" ~ "02282", # Skagway Municipality +
fips == "02231" ~ "02282", # Skagway-Yakutat-Angoon Census Area (merged) +
fips == "02232" ~ "02282", # Skagway-Hoonah-Angoon Census Area (merged)
fips == "02130" ~ "02195", # 7. Petersburg Borough = Petersburg Borough + Ketchikan Gateway Borough +
fips == "02275" ~ "02195", # Wrangell City and Borough +
fips == "02198" ~ "02195", # Prince of Wales-Hyder Census Area +
fips == "02201" ~ "02195", # Prince of Wales-Outer Ketchikan Census Area +
fips == "02280" ~ "02195", # Wrangell-Petersburg Census Area
# Arizona
fips == "04027" ~ "04012", # 1. La Paz County = La Paz County + Yuma County
# Colorado
fips == "08005" ~ "08001", # 1. Adams County = Adams County + Arapahoe County +
fips == "08013" ~ "08001", # Boulder County +
fips == "08014" ~ "08001", # Broomfield County +
fips == "08059" ~ "08001", # Jefferson County +
fips == "08123" ~ "08001", # Weld County
# Florida
fips == "12025" ~ "12086", # 1. Miami-Dade County = Miami-Dade County + Dade County
# Hawaii
fips == "15005" ~ "15009", # 1. Maui County = Maui County + Kalawao County
# Maryland
fips == "24031" ~ "24033", # 1. Prince George's County = Prince George's County + Montgomery County
# Montana
fips == "30113" ~ "30067", # 1. Park County = Park County + Yellowstone National Park (renamed)
# New Mexico
fips == "35061" ~ "35006", # 1. Cibola County = Cibola County + Valencia County
# South Dakota
fips == "46113" ~ "46102", # 1. Oglala Lakota County = Oglala Lakota County + Shannon County (renamed)
fips == "46131" ~ "46071", # 2. Jackson County = Jackson County + Washabaugh County (merged)
# Virginia
fips == "51600" ~ "51059", # 1. Fairfax County = Fairfax County + Fairfax City
fips == "51160" ~ "51665", # 2. Rockingham County = Rockingham County + Harrisonburg City
fips == "51830" ~ "51095", # 3. James City County = James City County + Williamsburg City
fips == "51830" ~ "51153", # 4. Prince William County = Manassas City +
fips == "51685" ~ "51153", # Manassas Park City
fips == "51530" ~ "51163", # 5. Rockbridge County = Rockbridge County + Buena Vista City
fips == "51630" ~ "51177", # 6. Spotsylvania County = Spotsylvania County + Fredericksburg City
fips == "51790" ~ "51015", # 7. Augusta County = Augusta County + Staunton City +
fips == "51820" ~ "51015", # Waynesboro City
fips == "51590" ~ "51143", # 8. Pittsylvania County = Pittsylvania County + Danville City
fips == "51595" ~ "51081", # 9. Greensville County = Greensville County + Emporia City
fips == "51540" ~ "51003", # 10. Albemarle County = Albemarle County + Charlottesville City
fips == "51515" ~ "51019", # 11. Bedford County = Bedford County + Bedford City (merged)
fips == "51780" ~ "51083", # 12. Halifax County = Halifax County + South Boston City (merged)
fips == "51620" ~ "51175", # 13. Southampton County = Southampton County + Franklin City
fips == "51560" ~ "51005", # 14. Alleghany County = Alleghany County + Clifton Forge City (merged)
fips == "51700" ~ "51199", # 15. York County = York County + Newport News City
# other broken codes
# fips == "05000" ~ "", # State code for Arkansas, no county
# fips == "13999" ~ "", # Georgia resident of unknown county
# fips == "38000" ~ "", # State code for North Dakota, no county
# fips == "48269" ~ "", # King county is the third least populous county in the US, with 265 residents in 2020. Maybe no deaths in 2021
# fips == "53000" ~ "", # State code for Washington, no county
TRUE ~ fips
)
)