knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Objetivo

Graficar la localizacion historica de los terremotos contenidos en NOAA earthquakes dataset

Ejemplo

Cargamos packages y limpiamos datos, usando "eq_clean_data". Ademas, seleccionamos un conjunto de la base de datos para usar de ejemplo.

library(Capstone)
library(dplyr)
library(readr)
library(lubridate)
library(leaflet)

file_name <- system.file("extdata", "signif.txt", package = "Capstone")
clean_data <- file_name %>%
              readr::read_tsv() %>%
              eq_clean_data() %>% 
              filter(COUNTRY == "CHILE", LOCATION_NAME == "Santiago") 

Graficamos para Chile los terremotos ocurridos historicamente en Santiago, CHILE.

library(ggplot2)
clean_data %>% 
ggplot( aes(x = DATE, 
            y = COUNTRY, 
            color = DEATHS, 
            size = EQ_PRIMARY, 
            fill = DEATHS)) + 
geom_timeline() +
geom_timelinelabel(aes(label = LOCATION_NAME, n_max = 5)) + 
        theme(legend.position="bottom",
              axis.title.x = element_blank(),
              axis.title.y = element_blank())+
        labs(size = "Richter scale value", color = "# deaths")

y ahora geográficamente. Cada pop up muestra location, Magnitude y Total deaths

clean_data %>%  
  dplyr::mutate(popup_text = eq_create_label(.)) %>% 
  eq_map(annot_col = "popup_text")


rumorale/Capstone documentation built on Dec. 31, 2022, 12:42 a.m.