zipcodeR
The R package for ZIP code analysis
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
# 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
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) Publications
Related Articles
A Spatial Analysis of New Jersey's Medical Cannabis Dispensary Accessibility
An isochrone-based GIS analysis revealing that over 756,000 New Jerseyans in 110 municipalities face 30+ minute drives to the nearest medical cannabis dispensary.
Apr 17, 2022New Jersey's official geocoding API now has a client for R
Using New Jersey's official state geocoding service just got easier! This post introduces njgeo, a new R package that simplifies working with New Jersey-specific spatial datasets.
Feb 4, 20222022 New Jersey Congressional Redistricting Map
An analysis and visualization of New Jersey's new congressional districts adopted by the Redistricting Commission, created using R and Leaflet.
Jan 2, 2022What Social Media Data Tells Us About the 2021 New Jersey Governor's Race
A sentiment analysis of tweets about the Murphy-Ciattarelli gubernatorial race reveals key differences in campaign rhetoric, word choice, and online engagement.
Oct 3, 2021