README.md

stldata

lifecycle Travis-CI Build
Status AppVeyor Build
Status Coverage
Status DOI CRAN_Status_Badge

The stlData package contains various data sets representing the City of St. Louis. These data sets are primary designed for teaching statistics, data science, and spatial data analysis using R.

Important Lifecycle Update

As of June 4, 2019, this package has been moved to a “questioning” lifecycle stats - some of its functionality has been shifted to the still-developing gateway package, while other aspects are better handeled by teaching students to import raw data sources. Development has therefore been suspended, with no current plans to return to this package in the future.

Installation

You can install stldata from Github with:

devtools::install_github("slu-openGIS/stlData")

Use with Simple Features

One goal of stldata is to provide accessible data for learning how to manipulate and map simple features objects in R. However, the installation of sf requires a number of dependencies. To make stldata as accessible as possible, sf is not required. If sf is not installed, only the data tables listed below will be fully accessible and functional.

Current Data

Data Tables

The package currently contains eight data tables stored as tibbles with quantitative data about the city:

Simple Features Objects

The package contains four sf objects describing the City of St. Louis:

Conversion of Tibbles to sf Objects

The following tibbles can be converted to sf objects using the stl_as_sf() function:

Input tables should not be quoted when the stl_as_sf() function is used:

asthma <- stl_as_sf(stl_tbl_asthma)

Useage

Basic Usage

Once the package is loaded, the data contained in stldata can be assigned to data frames in your global environment and then explored. For example, to load the stl_tbl_asthma data:

library("stldata")
asthma <- stl_tbl_asthma
str(asthma)

Additional examples and information are available in each table’s help file. For example:

?stl_tbl_asthma

Skill Building

The stl_tbl_murders and stl_tbl_water data have been created for practicing data wrangling. The murder data can be used for working with demographic data specifically, and the water data have both missing and duplicate information. The stl_tbl_sluPlaces table is meant for introducing basic mapping wither either plot(), ggplot2, or leaflet. All of the tables excepting stl_tbl_sluPlaces contain count or rate data suitable for plotting, and the data measured at the census tract level can be use for practicing joins with demographic data from tidycensus.

Mapping with sf

If you have the development version of ggplot2, the sf objects in the package can be mapped using the geom_sf() function:

ggplot() +
  geom_sf(data = stl_sf_boundary, fill = "#5d5d5d", color = "#5d5d5d") +
  geom_sf(data = stl_sf_historic, fill = "#d48a72", color = "#d48a72") +
  geom_sf(data = stl_sf_hydro, fill = "#72bcd4", color = "#72bcd4")  +
  labs(title = "Historic Districts", subtitle = "St. Louis, MO")

When the tibbles like stl_tbl_asthma are converted to sf objects, they can be mapped as well:

asthma <- stl_as_sf(stl_tbl_asthma)

ggplot() +
  geom_sf(data = asthma, mapping = aes(fill = pctAsthma), color = "#5d5d5d") +
  scale_fill_viridis(name = "Percent") +
  labs(title = "Crude Asthma Prevalence", subtitle = "St. Louis, MO")

Contributor Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.



chris-prener/stldata documentation built on June 10, 2019, 7:42 a.m.