README.md

Build Status

Earthquakes package

This is an R package for the Coursera course Mastering Software Development in R Capstone.

It consists of four components:

Full documentation, including a vignette, and unit tests are included.

Installation

# install.packages("devtools")
devtools::install_github("davidbody/earthquakes-package")

Usage

See the vignette for complete details.

Earthquake data

library(earthquakes)
library(dplyr)

filename <- system.file("extdata", "earthquakes.tsv.gz", package = "earthquakes")
earthquakes <- readr::read_delim(filename, delim = "\t")

clean_earthquakes <- earthquakes %>%
    eq_clean_data()

Earthquake time lines

library(ggplot2)

recent_earthquakes <- clean_earthquakes %>%
    filter(COUNTRY == "CANADA" | COUNTRY == "USA", YEAR >= 1980)

g <- ggplot(recent_earthquakes,
            aes(x = DATE, y = COUNTRY, size = EQ_PRIMARY, color = TOTAL_DEATHS))

g <- g + geom_timeline(alpha = 0.5)
g <- g + geom_timeline_label(aes(label = LOCATION_NAME, n_max = 3))
g <- g + theme_classic()
g <- g + theme(legend.position = "bottom",
               axis.line.y = element_blank(),
               axis.ticks.y = element_blank(),
               axis.title.y = element_blank())
g <- g + guides(color = guide_colorbar(title = "# deaths"),
                size = guide_legend("Richter scale value"))
g

Earthquake maps

clean_earthquakes %>%
    filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000) %>%
    dplyr::mutate(popup_text = eq_create_label(.)) %>%
    eq_map(annot_col = "popup_text")

earthquake map

This is a static image. The actual map will be interactive.



davidbody/earthquakes-package documentation built on May 14, 2019, 10:37 p.m.