This demonstrates how to use the RCapstone package.

Start by loading in the data.

raw_data<-readr::read_tsv(system.file("extdata", "signif.txt", package = "RCapstone"))

Then we can clean up the columns using eq_clean_data and eq_location_clean.

clean_data<-RCapstone::eq_clean_data(raw_data)
clean_data<-RCapstone::eq_location_clean(clean_data)

We can now visualise this data two different ways.

One is as a line plot of earthquakes over time.

c1<-subset(clean_data,COUNTRY %in% c("USA","CHINA"))
c2<-dplyr::filter(c1,!is.na(EQ_PRIMARY), !is.na(DEATHS))
ggplot2::ggplot(data=c2) +
  ggplot2::aes(
    x = DATE,
    size = EQ_PRIMARY,
    colour = DEATHS,
    group=COUNTRY
  ) +
  RCapstone::geom_timeline()

And can add labels for the top sized earthquakes. Note that it will match any earthquakes to the top n values.

c1<-subset(clean_data,COUNTRY %in% c("USA","CHINA"))
c2<-dplyr::filter(c1,!is.na(EQ_PRIMARY), !is.na(DEATHS))
ggplot2::ggplot(data=c2) +
  ggplot2::aes(
    x = DATE,
    size = EQ_PRIMARY,
    colour = DEATHS,
    group=COUNTRY,
    label=LOCATION_NAME
  ) +
  RCapstone::geom_timeline() + 
  RCapstone::geom_timeline_label()

The other way is spatially. We can start with a basic map.

c1<-dplyr::filter(clean_data,COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000)
RCapstone::eq_map(c1,annot_col = "DATE")

We can improve this with better annotations.

c1<-dplyr::filter(clean_data,COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000)
c2<-dplyr::mutate(c1,popup_text = RCapstone::eq_create_label(c1))
RCapstone::eq_map(c1,annot_col = "popup_text")


JamasEnright/RCapstone documentation built on May 7, 2019, 9:42 p.m.