knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
This package contains following functions.
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)
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)
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)
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")
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")
This package contains the following geoms.
A geom to render the timeline of earthquake with magnitude and total deaths.
A geom to add label to timeline of earthquake created by geom_timeline.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.