knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

Travis Status Build Status

NOAA package

This package contains following functions.

eq_clean_data()

It adds the column DATE and changes the type of LONGITUDE and LATITUDE columns. It takes a dataframe with NOAA earthquake data as input and returns a dataframe with DATE column and it also changes the type of LONGITUDE and LATITUDE column to numeric.

raw.noaa.df <- readr::read_tsv(system.file("extdata", "signif.txt", package = "NOAA"))
noaa.df <- NOAA::eq_clean_data(raw.noaa.df)

eq_location_clean()

It removes the country name from LOCATION_NAME column and also makes it Title case. This function makes an internal call to eq_clean_data() to ease the process. We could just call eq_location_clean() instead of calling both functions.

raw.noaa.df <- readr::read_tsv(system.file("extdata", "signif.txt", package = "NOAA"))
noaa.df <- NOAA::eq_location_clean(raw.noaa.df)

get_timeline()

The wrapper function for geom_timeline. Renders the timeline based on countries parameter. It takes the NOAA dataframe, a vector of countries and minimum and maximum values of timeline as input. It makes internal call to geom_timeline() and renders the output based on the value we give at "countries" attribute. To render a timeline of earthquakes irrespective of countries we need to pass "*" in the countries parameter.

NOAA::get_timeline(noaa.df, "*","2000-01-01","2010-01-01")
NOAA::get_timeline(noaa.df, c("CHINA", "INDIA"),"2000-01-01","2010-01-01")

For the output of get_timeline we could add the geom "geom_timeline_label()" which will add label to "n" number of earthquakes.

NOAA::get_timeline(noaa.df, c("CHINA", "INDIA"),"2000-01-01","2010-01-01") +
NOAA::geom_timeline_label(ggplot2::aes(x=DATE, location=LOCATION_NAME,xmin=xmin,xmax=xmax,size=EQ_PRIMARY,y=COUNTRY), n_max = 5)

eq_map()

It creates an interactive map with popup based on annot_col attribute. It takes the NOAA dataframe and annot_col value as input. The value of annot_col can be any column in the dataframe.

mexico.df <- dplyr::filter(noaa.df, COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000)
NOAA::eq_map(mexico.df, "DATE")

Map With Date

eq_create_label()

It creates a label with Location, Magnitude and Total Deaths.

mexico.df<- dplyr::mutate(mexico.df, popup_text = NOAA::eq_create_label(mexico.df))
NOAA::eq_map(mexico.df, "popup_text")

Map With Label

This package contains the following geoms.

geom_timeline()

A geom to render the timeline of earthquake with magnitude and total deaths.

geom_timeline_label()

A geom to add label to timeline of earthquake created by geom_timeline.



GopalSeshadri/NOAA documentation built on May 30, 2019, 7:59 p.m.