knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Overview

The goal of quakeTools is to clean and plot earthquake data from The Significant Database Earthquake of NOAA.

Examples

First step: extract and clean data

library(quakeTools)
library(ggplot2)
cleanquakes <- eq_clean_data(earthquakes)
plotquakes <- dplyr::filter(cleanquakes, COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000)

The function eq_clean_data receives NOAA dataframe (embedded in this package as earthquakes), creating and treating some columns. This function also calls eq_location_clean function to treat the LOCATION_NAME column specifically, as you could see below.

head(plotquakes[,c("DATE", "LATITUDE", "LONGITUDE", "LOCATION")])

First plot example: earthquake timeline

ggplot(plotquakes, aes(x = DATE, y = COUNTRY, size = EQ_PRIMARY, colour = DEATHS)) +
geom_timeline() +
xlab("Date") + ggplot2::ylab("") +
labs(size = "Richter scale", color = "# deaths" ) +
theme(axis.line.y=element_blank(),panel.background=element_blank())

Second plot example: earthquake timeline with annotation

ggplot(plotquakes, aes(x = DATE, y = COUNTRY, size = EQ_PRIMARY, colour = DEATHS)) +
geom_timeline() +
geom_timeline_label(aes(label = LOCATION, n_max = 6)) +
xlab("Date") + ggplot2::ylab("") +
labs(size = "Richter scale", color = "# deaths" ) +
theme(axis.line.y=element_blank(),panel.background=element_blank())

Third plot example: earthquake spots in map with date popup

eq_map(plotquakes, annot_col = "DATE")

Fourth plot example: earthquake spots in map with location, intensity and deaths popup

plotquakes$popup_text = eq_create_label(plotquakes)
eq_map(plotquakes, annot_col = "popup_text")


danielfsilva88/quakeTools documentation built on Sept. 13, 2020, 12:13 a.m.