knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This package contains functions to clean and visualise earthquake data.
library(readr) library(dplyr) library(stringr) library(lubridate) library(ggplot2) library(leaflet) library(Rcapstone)
The raw dataset is obtained from National Geophysical Data Center / World Data Service (NGDC/WDS): Significant Earthquake Database. National Geophysical Data Center, NOAA.
For convenience, the data has been preloaded into ./inst/extdata/dataset.txt
.
raw_data <- system.file("extdata", "dataset.txt", package = "Rcapstone")
This create a cleaned data for earthquakes since 01 Jan 1900, excluding data points with missing magnitude or intensity.
cleaned_data <- eq_clean_data(raw_data) cleaned_data <- eq_location_clean(cleaned_data) head(cleaned_data, 5)
ggplot(data = cleaned_data, aes(x = DATE, country = COUNTRY, label = LOCATION, magnitude = MAGNITUDE)) + geom_timeline(ctry = "MEXICO", xmin = dmy("01/01/2000"), xmax = dmy("01/01/2018")) + geom_timeline_label(n_max = 2, ctry = "MEXICO", xmin = dmy("01/01/2000"), xmax = dmy("01/01/2018")) + theme_classic()
cleaned_data %>% filter(COUNTRY == "MEXICO" & year(DATE) >= 2000) #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.