Vignette Info

This vignette provides a meaningful description of the package earthquakeR and how it should be used. The usage of all the functions are decsribed one by one

library(earthquakeR)
library(dplyr)
library(ggplot2)
library(grid)
library(leaflet)
library(lubridate)
library(magrittr)
library(readr)
library(stringi)
#knitr::opts_chunk$set(echo = TRUE, tidy = TRUE)

Read the raw data into a data frame

data <- eq_data()
head(data)

Clean the data for using in the visualization functions created

data <- eq_clean_data(data) %>% eq_location_clean()
head(data)

Plot earthquake timeline

 g <-  data %>%
    dplyr::filter(year(DATE) > 2000  & COUNTRY %in% c("CANADA")) %>%
    dplyr::mutate(TOTAL_DEATHS = as.numeric(TOTAL_DEATHS),
                  EQ_PRIMARY = as.numeric(EQ_PRIMARY)) %>%
    ggplot2::ggplot(ggplot2::aes(x = DATE,
                                 y = COUNTRY,
                                 colour = TOTAL_DEATHS,
                                 size = EQ_PRIMARY
    )) +
    geom_timeline()
g

Plot earthquake timeline label

g <-  data %>%
    dplyr::filter(year(DATE) > 2000  & COUNTRY %in% c("CANADA")) %>%
    dplyr::mutate(TOTAL_DEATHS = as.numeric(TOTAL_DEATHS),
                  EQ_PRIMARY = as.numeric(EQ_PRIMARY)) %>%
    ggplot2::ggplot(ggplot2::aes(x = DATE,
                                 y = COUNTRY,
                                 colour = TOTAL_DEATHS,
                                 size = EQ_PRIMARY
    )) +
    geom_timeline() +
      labs(size = "Richter scale value", color = "# deaths") +
         geom_timeline_label(ggplot2::aes(label = LOCATION_NAME), n_max = 3)
g

Visualizing earthquake on map

  data %>%
   dplyr::filter(YEAR > 2000 & neg.date == 0 & COUNTRY %in% c("MEXICO")) %>%
      dplyr::mutate(popup_text = eq_create_label(.)) %>%
   eq_map(annot_col = "popup_text")


abhinav-piplani/earthquakeR documentation built on May 23, 2019, 3:04 p.m.