Travis build status

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

NOAA Earthquake Analysis

This package has been developed as part of the capstone module for Coursera's Mastering Software Development in R Specialization. This package allows you to load earthquake data from the US National Centers for Environmental Information. These data contains information on destructive earthquakes from 2150 B.C. to the present that meet at least one of the following criteria:

Installation

You can install the released version of the NOAA earthquake package by:

library(devtools)
install_github("csgbloom/NOAAearthquake")
library(NOAAearthquake)

Examples

The function eq_clean_data():

df1 <- eq_clean_data(system.file("extdata", "earthquakes.tsv", package = "NOAAearthquake"))
head(df1$Date)

The function eq_location_clean():

df2 <- eq_location_clean(df1)
head(df2$Country)

The function geom_timeline():

library(tidyverse)
df2 %>% 
   dplyr::filter(Country %in% c("Mexico", "Turkey"), lubridate::year(Date) > 2000) %>% 
   ggplot2::ggplot(aes(x = Date, y = Country, color = `Total Deaths`, size = Mag)) +
   geom_timeline() +
   ggplot2::labs(size = "Richter scale value", col = "# Deaths")

The function theme_timeline():

df2 %>% 
   dplyr::filter(Country %in% c("Mexico", "Turkey"), lubridate::year(Date) > 2000) %>% 
   ggplot2::ggplot(aes(x = Date, y = Country, color = `Total Deaths`, size = Mag)) +
   geom_timeline() +
   theme_timeline() +
   ggplot2::labs(size = "Richter scale value", col = "# Deaths")

The function geom_timeline_label():

df2 %>% 
   dplyr::filter(Country %in% c("Mexico", "Turkey"), lubridate::year(Date) > 2000) %>% 
   ggplot2::ggplot(aes(x = Date, y = Country, color = `Total Deaths`, size = Mag)) +
   geom_timeline() +
   geom_timeline_label(aes(label = `Location Name`), n_max = 3) +
   theme_timeline() +
   ggplot2::labs(size = "Richter scale value", col = "# Deaths")

The function eq_map():

df2 %>% 
   dplyr::filter(Country == "Turkey", lubridate::year(Date) >= 2010) %>%  
   eq_map(annot_col = "Date")

Map with basic date label

The function eq_create_label():

df2 %>% 
   dplyr::filter(Country == "Turkey", lubridate::year(Date) >= 2010) %>%  
   dplyr::mutate(popup_text = eq_create_label(.)) %>%
   eq_map(annot_col = "popup_text")

Map with more detailed label



csgbloom/NOAAearthquake documentation built on April 12, 2021, 12:40 p.m.