knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The goal of quakeTools is to clean and plot earthquake data from The Significant Database Earthquake of NOAA.
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")])
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())
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())
eq_map(plotquakes, annot_col = "DATE")
plotquakes$popup_text = eq_create_label(plotquakes) eq_map(plotquakes, annot_col = "popup_text")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.