knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

statesRcontiguous?

Travis-CI Build Status CRAN_Status_Badge Project Status: Active – The project has reached a stable, usable state and is being actively developed.

statesRcontiguous provides a tiny (small enough for CRAN) package containing shapefiles for the following subdivisions of the United States of America:

library("DT")
library("statesRcontiguous")
library("tidyverse")
statesrcontiguous_shapefile_details %>%
  select(-path) %>%
  mutate(source = paste0("<a href='", "' target='_blank'>", "US Census Bureau", "</a>")) %>%
  knitr::kable(col.names = c("Subdivision of the US", "Shapefile/Info", "Year Updated", "Source"))

The sources of the data in the package (and the year they were last updated) is available from the following object:

statesRcontiguous::statesrcontiguous_shapefile_details

All shapefiles include a column called contiguous.united.states which allows the dataset to be restricted to the contiguous US very simply:

library(statesRcontiguous)
library(leaflet)
shp_contiguous_states <- shp_all_us_states %>%
  filter(contiguous.united.states)
leaflet(shp_contiguous_states) %>%
  addTiles() %>%
  addPolygons()

Installation

Install from CRAN as follows:

install.packages("statesRcontiguous")

To install the development build of statesRcontiguous, please use the following:

devtools::install_github("martinjhnhadley/statesRcontiguous")

Should I use this package?

This package provides only the three shapefiles (states, congressional districts, counties) included in the package. It is intended for where you have a reproducible need for shapefiles for the (contiguous) US and don't want to have to download the files on the fly.

You might prefer to use the tigris package which is available on CRAN, and provides tools to download any of the shapefiles from TIGER.

So why does this exist?

This package was designed for the University of Oxford's Interactive Data Network which exists to provide a visualisation service for academics at Oxford, using Shiny. The Shiny apps developed by researchers are not allowed to contain data files, instead data must be loaded from external DOI-issuing repositories like Figshare.

By providing a small utility package with these shapefiles in, researchers can easily create choropleth of the US.

License

This package includes shapefiles from the US Census Bureau. All shapefiles provided by the US Census Bureau are TIGER/Line shapefiles and are offered to the public free of charge, see TIGER/Line Shapefil Technical Documentation for details.

This package itself is made available under the MIT license.



martinjhnhadley/statesRcontiguous documentation built on May 21, 2019, 12:38 p.m.