Erquaker

This package contains functions for cleaning raw NOAA' significant earthquakes dataset eq_clean_data(raw). Raw is a data.frame which contains DATE, YEAR, MONTH, DAY, LATITUDE, LONGITUDE, TOTAL_DEATHS,EQ_PRIMARY,LOCATION_NAME varaibles. Dataset can be obtained from https://www.ngdc.noaa.gov/nndc/struts/form?t=101650&s=1&d=1

  library(dplyr)
  library(magrittr)
  library(erquaker)
  library(ggplot2)
  dataset_noaa_raw %>%
  eq_clean_data()%>%head()

Also for futher labeling of points we need trim LOCATION_NAME variable with eq_location_clean() function

d<-dataset_noaa_raw %>%
  eq_clean_data()%>%eq_location_clean()
head(d)

Now we can plot some information via geom_timeline function

p<-d%>%subset(COUNTRY=="USA" | COUNTRY=="CHINA")%>%subset(DATE>=as.Date("2000-01-01"))%>%
   ggplot(aes(DATE, COUNTRY, colour = DEATHS, size = EQ_PRIMARY, label = LOCATION_NAME)) +
   geom_timeline()+
   guides(size = guide_legend("Richter scale value")) +
   guides(colour = guide_colorbar("# Deaths", label.theme = element_text(angle = 45, size = 8 ))) +
   ylab("") +
   theme_classic() +
   theme(legend.position="bottom", axis.line.y = element_blank())
p

Also we can add labels for circle points with names of places where events happened. And n_max is how much biggest event to mark

p+geom_timeline_label(n_max=5)

The next step is mapping events with leaflet and eq_map() function

dataset_noaa_raw %>%
 eq_clean_data() %>%
   dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000) %>%
   eq_map()
   # For Date annotation popup
   # eq_map(annot_col="DATE")


dddbbb/erquaker documentation built on May 17, 2019, 9:11 a.m.