About zipcodeR

zipcodeR is an R package enabling breakthrough research across public health, epidemiology, economics, and environmental science. Created by Gavin Rozzi and published on CRAN, the package has been cited in Nature, Cancer Discovery, and other leading peer-reviewed journals.

Whether you're calculating distances between ZIP codes, looking up demographic information, performing spatial joins, or building maps, zipcodeR provides a clean, intuitive interface that handles the complexity of ZIP code data for you.

The package includes an embedded SQLite database with comprehensive ZIP code data, ensuring fast lookups without external API dependencies. It's well-documented, actively maintained, and follows modern R development best practices.

Research Impact

With 49 peer-reviewed citations and growing, zipcodeR has become essential infrastructure for spatial research across medicine, public health, economics, and environmental science.

View all 49 citations on Google Scholar

Installation

R Console
# Install from CRAN
install.packages("zipcodeR")

# Or install development version from GitHub
# install.packages("remotes")
remotes::install_github("gavinrozzi/zipcodeR")

Key Features

Distance Calculations

Compute geodesic distances between ZIP codes using the Haversine formula. Perfect for delivery routing, service area analysis, and proximity searches.

Demographic Data

Access population, income, housing, and other census statistics by ZIP code. Great for market research and demographic analysis.

Geographic Boundaries

Retrieve ZIP code boundary polygons for mapping and spatial analysis. Works seamlessly with sf and leaflet packages.

ZIP Code Lookups

Search ZIP codes by city, county, state, or coordinates. Reverse geocode lat/lon to ZIP codes instantly.

Example Usage

R Script
library(zipcodeR)

# Look up information for a ZIP code
zip_info <- reverse_zipcode("08901")

# Calculate distance between two ZIP codes
distance <- zip_distance("08901", "10001")

# Get all ZIP codes in a state
nj_zips <- search_state("NJ")

# Find ZIP codes within radius
nearby <- search_radius("08901", radius = 25)