library(RCapstone)
library(dplyr)
library(ggplot2)
library(readr)
library(grid)
library(lubridate)
library(leaflet)
library(scales)

Overview of the RCapstone R package created for visualizing U.S. National Oceanographic and Atmospheric Administation's (NOAA) dataset of significant earthquakes. The data examined is from NOAA database.

Installation

You can install RCapstone from github with:

library(devtools)
install_github("CarlosSilva34/RCapstone")
library(RCapstone)

Package functions

Exported functions available:

Read and clean data

The first function cleans the data for the visualization. It creates a DATE column in Date format, transforms latitude and longitude to numeric format and trims country from LOCATION_NAME.

filename <- system.file("extdata/signif.txt", package = "RCapstone")
data <- readr::read_delim(filename, delim = "\t")
eq_clean_data(data)

Timeline of earthquakes in US and China after 2000

These functions use ggplot2 package to visualize earthquake timeline. Thegeom_timeline() geom requires clean data. The aesthetics are x with dates, optional y for grouping by country,size and color. The geom_timeline_label() function requires label aesthetic. The theme_timeline() geom was added for better visualization.

data %>% eq_clean_data() %>%
filter(COUNTRY %in% c("USA", "CHINA"), YEAR >= 2000) %>%
ggplot(aes(x = DATE,
y = COUNTRY,
color = as.numeric(TOTAL_DEATHS),
size = as.numeric(EQ_PRIMARY)
)) +
geom_timeline() +
geom_timeline_label(aes(label = LOCATION_NAME), n_max = 5) +
theme_timeline() +
labs(size = "Richter scale value", color = "# deaths")

Map of earthquakes in Mexico

These functions use leaflet package to visualize earthquakes on a map using eq_map() function. Optional annotations can be created using eq_create_label() function. This creates an interactive map where user can click on individual points to get details.

```r data %>% eq_clean_data() %>% dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000) %>% dplyr::mutate(popup_text = eq_create_label(.)) %>% eq_map(annot_col = "popup_text")



CarlosSilva34/RCapstone documentation built on May 6, 2019, 4:10 p.m.