| Title: | Classification and Scoring of U.S. County and ZIP Code Rurality |
|---|---|
| Description: | Provides USDA Rural-Urban Continuum Codes (RUCC 2023), Rural-Urban Commuting Area codes (RUCA 2020), and a composite rurality score for all U.S. counties. Functions enable lookup by FIPS code, ZIP code, or county name, and easy merging with existing datasets. Data sources include the USDA Economic Research Service, U.S. Census Bureau American Community Survey, and Census TIGER/Line shapefiles. |
| Authors: | Cameron Wimpy [aut, cre] (ORCID: <https://orcid.org/0000-0002-2049-5229>) |
| Maintainer: | Cameron Wimpy <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0.9000 |
| Built: | 2026-05-22 09:06:38 UTC |
| Source: | https://github.com/cwimpy/rurality |
Joins rurality data onto an existing data frame by FIPS code.
add_rurality( data, fips_col = "fips", vars = c("rurality_score", "rurality_classification", "rucc_2023") )add_rurality( data, fips_col = "fips", vars = c("rurality_score", "rurality_classification", "rucc_2023") )
data |
A data frame with a FIPS code column. |
fips_col |
The name of the FIPS code column (default: "fips"). |
vars |
Which rurality variables to add. Default adds score and classification. Use "all" for all variables. |
The input data frame with rurality columns appended.
my_data <- data.frame(fips = c("05031", "06037", "48453"), value = 1:3) add_rurality(my_data) add_rurality(my_data, vars = "all")my_data <- data.frame(fips = c("05031", "06037", "48453"), value = 1:3) add_rurality(my_data) add_rurality(my_data, vars = "all")
Converts numeric rurality scores to classification labels.
classify_rurality(score)classify_rurality(score)
score |
A numeric vector of rurality scores (0-100). |
A character vector of classifications.
classify_rurality(c(15, 35, 55, 75, 90))classify_rurality(c(15, 35, 55, 75, 90))
A county-level crosswalk combining the four major U.S. rurality
classification schemes (USDA RUCC, USDA RUCA, NCHS Urban-Rural, and OMB
Metropolitan/Micropolitan), along with Census urban/rural percentage and
ACS 2022 5-year demographic covariates. Used by rurality_spec() to run
specification curve analyses comparing schemes.
county_crosswalkcounty_crosswalk
A tibble with 3,143 rows and the following columns:
5-digit county FIPS code (character)
2-digit state FIPS code (character)
3-digit county FIPS code (character)
County name
Two-letter state abbreviation
USDA Rural-Urban Continuum Code 2023 (1-9)
County-level RUCA 2020 (modal ZCTA code, 1-10)
NCHS Urban-Rural Classification 2023 (1-6)
OMB class: "metro", "micro", or "noncore"
Percent of county population in Census urban areas (2020)
ACS 2022 5-year total population
ACS 2022 5-year median household income
Percent of adults 25+ with bachelor's degree or higher
Percent non-Hispanic white
log(median household income)
log(total population)
Population per square mile of land area
USDA Economic Research Service: RUCC 2023, RUCA 2020
NCHS Urban-Rural Classification Scheme for Counties 2023
U.S. Office of Management and Budget, CBSA delineations
U.S. Census Bureau: 2020 Decennial (urban/rural), ACS 2022 5-year
county_crosswalkcounty_crosswalk
A dataset containing rurality scores, USDA classifications, and demographic data for all U.S. counties. Includes RUCC 2023 codes, population density, distance to metro areas, and a composite rurality score.
county_ruralitycounty_rurality
A tibble with approximately 3,233 rows and 23 columns:
5-digit county FIPS code (character)
2-digit state FIPS code (character)
3-digit county FIPS code (character)
Two-letter state abbreviation
County name
2020 Census population
ACS 2022 5-year population estimate
Land area in square miles
Population per square mile
USDA Rural-Urban Continuum Code (1-9)
RUCC code description
OMB designation: Metropolitan, Micropolitan, or Nonmetro
County centroid latitude
County centroid longitude
Distance to nearest large metro (>1M pop) in miles
Distance to nearest medium metro (250K-1M) in miles
Distance to nearest small metro (50K-250K) in miles
RUCC-derived score component (0-100)
Population density score component (0-100)
Distance to metro score component (0-100)
Composite rurality score (0-100)
Classification: Urban, Suburban, Mixed, Rural, Very Rural
ACS 2022 median household income
ACS 2022 median age
The composite rurality score is calculated as a weighted average:
RUCC score: 55\
Population density score: 28\
Distance to metro score: 17\
Classifications:
80-100: Very Rural
60-79: Rural
40-59: Mixed
20-39: Suburban
0-19: Urban
USDA Economic Research Service, Rural-Urban Continuum Codes 2023
U.S. Census Bureau, American Community Survey 2022 5-Year Estimates
U.S. Census Bureau, TIGER/Line Shapefiles 2020
# View the data county_rurality # Filter to rural counties library(dplyr) county_rurality |> filter(rurality_classification == "Very Rural") # Arkansas counties county_rurality |> filter(state_abbr == "AR")# View the data county_rurality # Filter to rural counties library(dplyr) county_rurality |> filter(rurality_classification == "Very Rural") # Arkansas counties county_rurality |> filter(state_abbr == "AR")
Returns the USDA Rural-Urban Commuting Area code (2020) for one or more ZIP codes or ZCTAs.
get_ruca(zip)get_ruca(zip)
zip |
A character vector of 5-digit ZIP codes. |
RUCA codes range from 1 (metropolitan core) to 10 (rural). The primary code reflects the majority commuting pattern; the secondary code captures additional commuting flows.
A tibble with columns: zip, primary_ruca, secondary_ruca, state. Returns NA values for ZIPs not in the RUCA dataset.
get_ruca("72401") get_ruca(c("72401", "90210", "59801"))get_ruca("72401") get_ruca(c("72401", "90210", "59801"))
Returns the USDA Rural-Urban Continuum Code (2023) for one or more counties.
get_rucc(fips)get_rucc(fips)
fips |
A character vector of 5-digit county FIPS codes. |
An integer vector of RUCC codes (1-9), or NA for unmatched FIPS.
get_rucc("05031") get_rucc(c("05031", "06037"))get_rucc("05031") get_rucc(c("05031", "06037"))
Returns the full rurality record for one or more county FIPS codes.
get_rurality(fips)get_rurality(fips)
fips |
A character vector of 5-digit county FIPS codes. |
A tibble with rurality data for the matched counties.
get_rurality("05031") get_rurality(c("05031", "06037", "48453"))get_rurality("05031") get_rurality(c("05031", "06037", "48453"))
USDA Rural-Urban Commuting Area codes (2020) for approximately 41,000 ZCTAs.
ruca_codesruca_codes
A tibble with columns:
5-digit ZIP/ZCTA code (character)
Two-letter state abbreviation
Primary RUCA code (1-10)
Secondary RUCA code (1-10)
USDA Economic Research Service, Rural-Urban Commuting Area Codes 2020
Returns the composite rurality score (0-100) for one or more counties.
rurality_score(fips)rurality_score(fips)
fips |
A character vector of 5-digit county FIPS codes. |
A numeric vector of rurality scores, or NA for unmatched FIPS.
rurality_score("05031") rurality_score(c("05031", "06037", "48453"))rurality_score("05031") rurality_score(c("05031", "06037", "48453"))
Runs a specification curve across four rurality classification schemes (RUCC, RUCA, NCHS, OMB), two functional forms (ordinal and binary metro/nonmetro), and three covariate sets, for one or more user-supplied county-level outcome variables. Returns a tidy data frame of coefficient estimates suitable for plotting or further analysis.
rurality_spec( data, outcome, fips_col = "fips", covariates = NULL, schemes = c("rucc", "ruca", "nchs", "omb"), forms = c("ordinal", "binary"), covar_sets = c("minimal", "full", "state_fe"), plot = TRUE )rurality_spec( data, outcome, fips_col = "fips", covariates = NULL, schemes = c("rucc", "ruca", "nchs", "omb"), forms = c("ordinal", "binary"), covar_sets = c("minimal", "full", "state_fe"), plot = TRUE )
data |
A data frame containing a 5-digit county FIPS column and at least one numeric outcome variable. |
outcome |
A character vector naming one or more outcome columns in
|
fips_col |
Name of the FIPS column in |
covariates |
Optional character vector of additional covariate column
names already present in |
schemes |
Character vector of schemes to include. Any subset of
|
forms |
Character vector of functional forms. Any subset of
|
covar_sets |
Character vector of built-in covariate sets to use.
Any subset of |
plot |
Logical. If |
rurality_spec() joins the package's county_crosswalk dataset (FIPS
backbone with RUCC, RUCA, NCHS, OMB, and ACS covariates) onto data by
FIPS code, then fits OLS models for every combination of scheme, form,
and covariate set requested.
Built-in covariate sets (using ACS 2022 variables from the crosswalk):
"minimal": log(population) + log(median income)
"full": minimal + percent BA or higher + percent non-Hispanic white
"state_fe": full + state fixed effects (factor(state_fips))
Ordinal predictors are standardized (mean 0, SD 1) so that coefficients are comparable across schemes with different scale lengths (RUCC: 1-9, RUCA: 1-10, NCHS: 1-6, OMB: 1-3).
Binary predictors code metropolitan = 0, nonmetropolitan = 1, using standard cutpoints: RUCC >= 4, RUCA >= 4, NCHS >= 5, OMB != "metro".
Any user-supplied covariates are appended to all three built-in covariate
sets.
A tibble with one row per specification per outcome, containing:
Outcome variable name
Rurality scheme (rucc, ruca, nchs, omb)
Functional form (ordinal or binary)
Covariate set label
Number of observations
Coefficient on the rurality predictor
Standard error
t-statistic
p-value
Lower 95% confidence interval
Upper 95% confidence interval
Model R-squared
## Not run: # Minimal example with a built-in outcome proxy library(dplyr) # Attach a synthetic outcome to the crosswalk df <- county_rurality |> select(fips) |> mutate(y = rnorm(n())) results <- rurality_spec(df, outcome = "y") print(results) ## End(Not run)## Not run: # Minimal example with a built-in outcome proxy library(dplyr) # Attach a synthetic outcome to the crosswalk df <- county_rurality |> select(fips) |> mutate(y = rnorm(n())) results <- rurality_spec(df, outcome = "y") print(results) ## End(Not run)