knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
#add this to run in development: 
#devtools::load_all(".")

Overview

This package was developed for the capstone project of the Mastering Software Development in R Coursera Specialization. The package provides functions for visualizing the NOAA Significant Earthquakes dataset.

Loading and cleaning the dataset

library(msdrCourseraCapstonePackage)
library(magrittr)
library(dplyr)
library(lubridate)
library(ggplot2)

data_path <- system.file("extdata", "signif.txt", package = "msdrCourseraCapstonePackage")

eq_data_raw <- read.delim(data_path)

eq_data <- 
  eq_data_raw %>% 
  eq_clean_data() %>% 
  eq_location_clean()

Visualizing the data with timelines

eq_data_plot <- eq_data %>% filter(COUNTRY %in% c("CANADA", "USA"))
ggplot(eq_data_plot, aes(x = DATE)) + 
  geom_timeline() + 
  theme_eq
# use size and color of points to represent magnitude and number of casualties, and set alpha to 0.3
ggplot(eq_data_plot, aes(x = DATE, y = COUNTRY, min_date = as.Date("1900-01-01"), max_date = as.Date("2000-01-01"), size = EQ_PRIMARY, color = TOTAL_DEATHS)) + 
  geom_timeline(alpha = 0.3) + 
  geom_timeline_label(aes(n_max = 3, label = LOCATION_NAME)) + 
  theme_eq

Visualizing the data with maps

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


jtgit-la/msdrCourseraCapstonePackage documentation built on May 10, 2020, 5:01 p.m.