knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
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:
You can install the released version of the NOAA earthquake package by:
library(devtools) install_github("csgbloom/NOAAearthquake") library(NOAAearthquake)
The function eq_clean_data():
Date
field from the original Year
, Mo
and Dy
fields, adding 01-01 where no month or day in original datadf1 <- eq_clean_data(system.file("extdata", "earthquakes.tsv", package = "NOAAearthquake")) head(df1$Date)
The function eq_location_clean():
Location Name
field into Location Name
and Country
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():
Location Name
labels to the earthquakes of the highest magnitude for that year rangen_max
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")
The function eq_create_label():
Location
, Magintude
and Total Deaths
fieldsdf2 %>% dplyr::filter(Country == "Turkey", lubridate::year(Date) >= 2010) %>% dplyr::mutate(popup_text = eq_create_label(.)) %>% eq_map(annot_col = "popup_text")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.