Earthquakes4Coursera has been developed in a context of the Coursera's course "Mastering Software Development in R Capstone". The goal of the package is to visualize earthquakes registered in NOAA Significant Earthquake Database.
You can install Earthquakes4Coursera from github with:
# install.packages("devtools")
devtools::install_github("Valentin-Konoshenko/Earthquakes4Coursera")
It allows to visualize earthquakes in two ways:
This is a basic example of plotting a timeline:
library(Earthquakes4Coursera)
library(dplyr)
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 3.4.4
NOAAC <- file_read() %>% eq_clean_data()
NOAAC %>%
dplyr::filter(COUNTRY %in% c("USA"),
between(lubridate::year(DATE), 2000, 2017)) %>%
ggplot(aes(x = DATE,
color = DEATHS,
size = EQ_PRIMARY)) +
geom_timeline() +
theme_timeline() +
labs(size = "Richter scale value", colour = "# deaths") +
geom_timeline_label(aes(label = LOCATION_NAME), n_max = 5)
The following timeline stratifies the earthquakes by countries:
NOAAC %>%
dplyr::filter(COUNTRY %in% c("USA", "CHINA"),
between(lubridate::year(DATE), 2008, 2011)) %>%
ggplot(aes(x = DATE,
y = COUNTRY,
color = DEATHS,
size = EQ_PRIMARY)) +
geom_timeline() +
theme_timeline() +
labs(size = "Richter scale value", color = "# deaths") +
geom_timeline_label(aes(label = LOCATION_NAME), n_max = 3)
library(lubridate)
NOAAC %>%
dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2014) %>%
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.