| Title: | Classification and Scoring of U.S. County and ZIP Code Rurality |
| Version: | 0.1.0 |
| 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. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Depends: | R (≥ 4.1.0) |
| Imports: | dplyr, rlang, stringr |
| Suggests: | ggplot2, knitr, rmarkdown, sf, tigris, testthat (≥ 3.0.0) |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| LazyData: | true |
| URL: | https://github.com/cwimpy/rurality, https://rurality.app |
| BugReports: | https://github.com/cwimpy/rurality/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-04-04 13:49:52 UTC; cwimpy |
| Author: | Cameron Wimpy |
| Maintainer: | Cameron Wimpy <cwimpy@astate.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-04-10 09:30:02 UTC |
Merge Rurality Data onto a Data Frame
Description
Joins rurality data onto an existing data frame by FIPS code.
Usage
add_rurality(
data,
fips_col = "fips",
vars = c("rurality_score", "rurality_classification", "rucc_2023")
)
Arguments
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. |
Value
The input data frame with rurality columns appended.
Examples
my_data <- data.frame(fips = c("05031", "06037", "48453"), value = 1:3)
add_rurality(my_data)
add_rurality(my_data, vars = "all")
Classify a Rurality Score
Description
Converts numeric rurality scores to classification labels.
Usage
classify_rurality(score)
Arguments
score |
A numeric vector of rurality scores (0-100). |
Value
A character vector of classifications.
Examples
classify_rurality(c(15, 35, 55, 75, 90))
County-Level Rurality Data for the United States
Description
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.
Usage
county_rurality
Format
A tibble with approximately 3,233 rows and 23 columns:
- fips
5-digit county FIPS code (character)
- state_fips
2-digit state FIPS code (character)
- county_fips
3-digit county FIPS code (character)
- state_abbr
Two-letter state abbreviation
- county_name
County name
- pop_2020
2020 Census population
- acs_pop
ACS 2022 5-year population estimate
- land_area_sqmi
Land area in square miles
- pop_density
Population per square mile
- rucc_2023
USDA Rural-Urban Continuum Code (1-9)
- rucc_description
RUCC code description
- omb_designation
OMB designation: Metropolitan, Micropolitan, or Nonmetro
- lat
County centroid latitude
- lng
County centroid longitude
- dist_large_metro
Distance to nearest large metro (>1M pop) in miles
- dist_medium_metro
Distance to nearest medium metro (250K-1M) in miles
- dist_small_metro
Distance to nearest small metro (50K-250K) in miles
- rucc_score
RUCC-derived score component (0-100)
- density_score
Population density score component (0-100)
- distance_score
Distance to metro score component (0-100)
- rurality_score
Composite rurality score (0-100)
- rurality_classification
Classification: Urban, Suburban, Mixed, Rural, Very Rural
- median_income
ACS 2022 median household income
- median_age
ACS 2022 median age
Details
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
Source
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
Examples
# 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")
Look Up RUCA Code by ZIP Code
Description
Returns the USDA Rural-Urban Commuting Area code (2020) for one or more ZIP codes or ZCTAs.
Usage
get_ruca(zip)
Arguments
zip |
A character vector of 5-digit ZIP codes. |
Details
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.
Value
A tibble with columns: zip, primary_ruca, secondary_ruca, state. Returns NA values for ZIPs not in the RUCA dataset.
Examples
get_ruca("72401")
get_ruca(c("72401", "90210", "59801"))
Get RUCC Code for a County
Description
Returns the USDA Rural-Urban Continuum Code (2023) for one or more counties.
Usage
get_rucc(fips)
Arguments
fips |
A character vector of 5-digit county FIPS codes. |
Value
An integer vector of RUCC codes (1-9), or NA for unmatched FIPS.
Examples
get_rucc("05031")
get_rucc(c("05031", "06037"))
Look Up Rurality Data by FIPS Code
Description
Returns the full rurality record for one or more county FIPS codes.
Usage
get_rurality(fips)
Arguments
fips |
A character vector of 5-digit county FIPS codes. |
Value
A tibble with rurality data for the matched counties.
Examples
get_rurality("05031")
get_rurality(c("05031", "06037", "48453"))
RUCA Code Data for U.S. ZIP Codes
Description
USDA Rural-Urban Commuting Area codes (2020) for approximately 41,000 ZCTAs.
Usage
ruca_codes
Format
A tibble with columns:
- zip
5-digit ZIP/ZCTA code (character)
- state
Two-letter state abbreviation
- primary_ruca
Primary RUCA code (1-10)
- secondary_ruca
Secondary RUCA code (1-10)
Source
USDA Economic Research Service, Rural-Urban Commuting Area Codes 2020
Get Rurality Score for a County
Description
Returns the composite rurality score (0-100) for one or more counties.
Usage
rurality_score(fips)
Arguments
fips |
A character vector of 5-digit county FIPS codes. |
Value
A numeric vector of rurality scores, or NA for unmatched FIPS.
Examples
rurality_score("05031")
rurality_score(c("05031", "06037", "48453"))