knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(tibble)
{zipcodeR}
is an R package that makes working with ZIP codes in R easier. It provides data on all U.S. ZIP codes using multiple open data sources, making it easier for social science researchers and data scientists to work with ZIP code-level data in data science projects using R.
The latest update to {zipcodeR}
includes new functions for searching ZIP codes at various geographic levels & geocoding.
You can install the released version of zipcodeR from CRAN with:
install.packages("zipcodeR")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("gavinrozzi/zipcodeR")
{zipcodeR}
in PublicationsIf you use {zipcodeR}
in a publication, please cite the following journal article.
A BibTeX entry for LaTeX users is:
@article{ROZZI2021100099, title = {zipcodeR: Advancing the analysis of spatial data at the ZIP code level in R}, journal = {Software Impacts}, volume = {9}, pages = {100099}, year = {2021}, issn = {2665-9638}, doi = {https://doi.org/10.1016/j.simpa.2021.100099}, url = {https://www.sciencedirect.com/science/article/pii/S2665963821000373}, author = {Gavin C. Rozzi}, keywords = {ZIP code, R, ZCTA, ZIP code tabulation area, zipcodeR}, abstract = {The United States Postal Service (USPS) assigns unique identifiers for postal service areas known as ZIP codes which are commonly used to identify cities and regions throughout the United States in datasets. Despite the widespread use of ZIP codes, there are challenges in using them for geospatial analysis in the social sciences. This paper presents zipcodeR, an R package that facilitates analysis of ZIP code-level data by providing an offline database of ZIP codes and functions for geocoding, normalizing and retrieving data about ZIP codes and relating them to other geographies in R without depending on any external services.} }
# Load zipcodeR into R library(zipcodeR)
search_state('NJ')
zip_distance('08901','08731')
zip_codes <- tribble(~zip_a, ~zip_b, "08731", "08901", "08734", "08005") zip_distance(zip_codes$zip_a,zip_codes$zip_b)
geocode_zip('08901')
reverse_zipcode('08901')
search_county('Ocean','NJ')
search_city('Jersey City','NJ')
search_tz('Eastern')
get_tracts('08731')
Documentation for the current release is available here. See the reference section for full details on how to use each of the functions provided by zipcodeR.
This project was inspired by the excellent uszipcode library for Python and utilizes the same backend database released by its author under the MIT license. This project also incorporates open data from the U.S. Census Bureau and Department of Housing & Urban Development.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.