This is an overview of an R package that contains functions to read in, clean, and visuaize earthquakes data available from the NOAA dataset.
library(software.dev.capstone) library(readr) library(tidyr) library(dplyr) library(lubridate) library(stringr) library(ggplot2) library(grid) library(leaflet)
The R Capstone package is composed of the following functions:
eq_clean_data: reads in and cleans the earthquakes dataset, including creating a date variable and making latitude/longitude numeric eq_location_clean: specifically cleans the location_name variable from the earthquake dataset geom_timeline: visualizes a timeline of the earthquakes in the dataset geom_timeline_label: creates labels that appear on the timeline of earthquakes visualization eq_map: creates a map of the earthquakes in the dataset eq_create_label: creates pop-up labels that appear on the map of earthquakes
The following packages are loaded and required by the package.
library(software.dev.capstone) library(readr) library(tidyr) library(dplyr) library(lubridate) library(stringr) library(ggplot2) library(grid) library(leaflet)
Data files can be found at
list.files(system.file("signif.txt", package = "software.dev.capstone"))
df <- eq_clean_data("signif.txt")
df <- eq_location_clean(intermediate_data)
ggplot() + geom_timeline(aes(x = DATE, y = COUNTRY, color = TOTAL_DEATHS)
ggplot() + geom_timeline(aes(x = DATE, y = COUNTRY, color = TOTAL_DEATHS) + geom_timeline_label(aes(x = DATE, y = COUNTRY, magnitude = EQ_PRIMARY, label = LOCATION_NAME, n_max = 5))
readr::read_delim("earthquakes.tsv.gz", delim = "\t") %>% eq_clean_data() %>% dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000) %>% eq_map(annot_col = "DATE")
readr::read_delim("earthquakes.tsv.gz", delim = "\t") %>% eq_clean_data() %>% dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000) %>% 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.