About zipcodeR

zipcodeR is an R package designed to make working with U.S. ZIP code data simple and efficient. Created by Gavin Rozzi and published on CRAN, the package is used by researchers, data scientists, and analysts nationwide for geospatial analysis and demographic research.

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.

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)