README.md

Travis-CI Build Status

Earthquakes4Coursera

Earthquakes4Coursera has been developed in a context of the Coursera's course "Mastering Software Development in R Capstone". The goal of the package is to visualize earthquakes registered in NOAA Significant Earthquake Database.

Installation

You can install Earthquakes4Coursera from github with:

# install.packages("devtools")
devtools::install_github("Valentin-Konoshenko/Earthquakes4Coursera")

Usage

It allows to visualize earthquakes in two ways:

Examples of timelines

This is a basic example of plotting a timeline:

library(Earthquakes4Coursera)
library(dplyr)
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 3.4.4
NOAAC <- file_read() %>% eq_clean_data()
NOAAC %>%
  dplyr::filter(COUNTRY %in% c("USA"),
                between(lubridate::year(DATE), 2000, 2017)) %>%
  ggplot(aes(x = DATE,
             color = DEATHS,
             size = EQ_PRIMARY)) +
  geom_timeline() +
  theme_timeline() +
  labs(size = "Richter scale value", colour = "# deaths") +
  geom_timeline_label(aes(label = LOCATION_NAME), n_max = 5)

The following timeline stratifies the earthquakes by countries:

NOAAC %>%
  dplyr::filter(COUNTRY %in% c("USA", "CHINA"),
                between(lubridate::year(DATE),  2008, 2011)) %>%
  ggplot(aes(x = DATE,
             y = COUNTRY,
             color = DEATHS,
             size = EQ_PRIMARY)) +
  geom_timeline() +
  theme_timeline() +
  labs(size = "Richter scale value", color = "# deaths") +
  geom_timeline_label(aes(label = LOCATION_NAME), n_max = 3)

Example of mapping

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


Valentin-Konoshenko/Earthquakes4Coursera documentation built on May 23, 2019, 1:08 p.m.