The MSDRCapstone3 package provides helper functions to reasd and clean NOAA significant earthquakes data for visual anlyses of timeline map and leaflet map.

You can install MSDRCapstone3 from github with:

# install.packages("devtools")
devtools::install_github("nobuhiroK/MSDRCapstone3")

Packages to import

library(MSDRCapstone3)
library(dplyr)
library(magrittr)
library(ggplot2)
library(leaflet)

Loading Data

row data from package data

quakes <- read_signif()

row data from NOAA website

quakes <- read_signif(URL=True)

cleaned data

quakes <- eq_clean_data()

cleaned location data

quakes <- eq_location_clean()

Timeline plot

simple timeline map

quakes%>%
dplyr::filter(COUNTRY %in% c('USA', 'JAPAN')) %>%
dplyr::filter(DATE > '2000-01-01') %>%
ggplot(aes(x = DATE,
           y = COUNTRY,
           color = as.numeric(TOTAL_DEATHS),
           size = as.numeric(EQ_PRIMARY)
           )) +
  geom_timeline() +
  labs(size = "Richter scale value", color = "# deaths")

timeline map with annotation

quakes%>%
dplyr::filter(COUNTRY %in% c('USA', 'JAPAN')) %>%
dplyr::filter(DATE > '2000-01-01') %>%
    ggplot(aes(x = DATE,
               y = COUNTRY,
               colour = as.numeric(TOTAL_DEATHS),
               size = as.numeric(EQ_PRIMARY)))+
  geom_timeline()+
  geom_timeline_label(aes(magnitude = as.numeric(EQ_PRIMARY),label = LOCATION_NAME, n_max = 5)) +
   scale_size_continuous(name = 'Richter scale value') +
   scale_color_continuous(name = '# of Deaths') 

Leaflet map

annotation with selected column 'DATE'

quakes%>%
dplyr::filter(COUNTRY %in% c('JAPAN')) %>%
dplyr::filter(DATE > '2000-01-01') %>%
eq_map(annot_col="DATE")

annotation with custom made column 'popup' with eq_create_label()

quakes %>%
dplyr::filter(COUNTRY %in% c('JAPAN')) %>%
dplyr::filter(DATE > '2000-01-01') %>%
dplyr::mutate(popup_text = eq_create_label(.)) %>%
eq_map(annot_col = "popup_text")


nobuhiroK/MSDRCapstone3 documentation built on May 31, 2019, 8:49 p.m.