knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  warning = FALSE,
  message = FALSE
)
library(Capstone)

This package was built as the first assignment for the "Mastering Software Development in R Capstone" course on Coursera. It provides functions to work with the NOAA Significant Earthquakes dataset. The data, which comes with this package, comes from the NOAA Significant Earthquake Database. For further information see: https://www.ngdc.noaa.gov/nndc/struts/form?t=101650&s=1&d=1.

Loading NOAA data

In order to load the data into your R-environment, follow the example below:

filename<-system.file("extdata","signif.txt",  package = "Capstone")
data<-data <- readr::read_delim(filename, delim = "\t")

The data is stored in the inst/extdata sub-dirctory of this package.

Cleaning the data

This package comes with a function eq_clean_data which cleans the raw NOAA data frame.

data <- eq_clean_data(data)

Visualization Tools

The package contains the following visualization methods/functions:

geom_timeline

library(dplyr)
library(lubridate)
library(magrittr)
library(ggplot2)
  data %>%
  dplyr::filter(COUNTRY == c("MEXICO","China") & lubridate::year(DATE) >= 2010) %>%
  ggplot(aes(x=DATE,y=COUNTRY,color=TOTAL_DEATHS,size=EQ_PRIMARY, label=LOCATION_NAME)) +
  geom_timeline(alpha=0.7) +
  theme(legend.position="bottom", legend.box="horizontal", plot.title=element_text(hjust=0.5)) +
  ggtitle("Earthquakes Timeline") +
  labs(size = "Richter scale value", color = "# Deaths")

geom_timeline_label

 data %>%
 dplyr::filter(COUNTRY == c("USA","CHINA") & lubridate::year(DATE) >= 2008) %>%
  ggplot(aes(x=DATE,y=COUNTRY,color=TOTAL_DEATHS,size=EQ_PRIMARY)) +
  geom_timeline(alpha=.5) +
  geom_timelinelabel(aes(label=LOCATION_NAME),n_max=3) +
  theme(legend.position="bottom", legend.box="horizontal", plot.title=element_text(hjust=0.5)) +
  ggtitle("Earthquakes Visualization Tool") +
  labs(size = "Richter scale value", color = "# Deaths")

eq_map

data %>%
   dplyr::filter(COUNTRY == "USA" & lubridate::year(DATE) >= 1990) %>%
   eq_map(annot_col = "DATE")

eq_create_label

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


mkaywins/Capstone_project documentation built on Feb. 24, 2020, 8:36 p.m.