/NoaaEarthquakeAnalyzer

R Package to manipulate and Visualize NOAA Dataset.

Primary LanguageRGNU General Public License v3.0GPL-3.0

NOAA_Earthquake_Analyzer

R-CMD-check

Build Status

NOAA_Earthquake_Analyzer Package

The package can be used to read, clean the data and visualize the data from the NOAA Significant Earthquake Database. All the operations are done as per the instructions given in the Coursera: Mastering Software Development in R Capstone Course

Installation

To load the package. You must first install devtools package from CRAN.

install.packakes('devtools') # installing devtools

devtools::install_github('SanjayShetty01/NOAAEarthquakeAnalyzer')

Usage

The NOAA dataset is already loaded in the package as earthquakesdata. But if you have a downloaded .tsv raw dataset from the NOAA wesite. then you could use read_data function to read the dataset unto the R environment and load it as a r dataframe.

eq_clean_data : The function removes unwanted columns, creates a DATE column and also cleans the location column.

geom_timeline : This function creates ggplot visualization of the timelines of occurrence of earthquake in the specified country (or countries) (use y variable to specify the country of interest [more in the vignettes folder])

geom_timeline_label : The function creates a annotation of the location of the earthquake over the timeline visualization of the data.

eq_map : The function creates a leaflet map (interactive) of the location of the earthquakes and you would specify which column to be shown as a pop-up text.

eq_create_label : The function creates a string vector for the eq_map function, which displays the important information (location, magnitude and total amount of deaths due to the earthquakes.) on the leaflet map.

Example

library(NoaaEarthquakeAnalyzer)

# Getting the data

data = NoaaEarthquakeAnalyzer::earthquakesdata

#the data contains a lot of unnessacary data we would use `eq_clean_data` for cleaning the data.
cleanedData =  eq_clean_data(data)

Visualization Tools

  1. Timeline plot
cleanedData %>%
  filter(COUNTRY %in% 'ITALY',
         Year >= 1000 &
           Year <= 2000) %>% 
  ggplot(.,aes(x = DATE, 
               y = COUNTRY, 
               color = `Total Deaths`,
               size = Mag))+
  geom_timeline() 

timelinePlot

  1. Labelling the timeline plot
DataViz = cleanedData %>%
            filter(COUNTRY %in% 'YEMEN',
              Year >= 1000 &
              Year <= 2000)

ggplot(DataViz,aes(x = DATE,
               y = COUNTRY, 
               color = `Total Deaths`,
               size = Mag))+
  geom_timeline()+
  geom_timeline_label(tags = DataViz$Location.Name)

timelineLabelPlot

  1. Map Plot
data %>% 
  eq_clean_data(.) %>%  
  dplyr::filter(COUNTRY == "ITALY" )%>%   
  dplyr::mutate(popup_text = eq_create_label(.)) %>% 
  eq_map(annot_col = "popup_text")

mapPlot

We could specify the type of information that should be displayed.

#specifying the dates

data %>%
  eq_clean_data() %>% 
  dplyr::filter(lubridate::year(DATE) >= 1855) %>% 
  eq_map(annot_col = "DATE")

mapPlotDate