## ----setup, include = FALSE----------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
## ----warning=F,message=F,eval=F------------------------------------------
#
# if(!("devtools" %in% installed.packages())){install.packages("devtools")}
# devtools::install_github("jyjek/jyjekNOAA")
# library(jyjekNOAA)
#
## ----warning=F,message=F-------------------------------------------------
library(jyjekNOAA)
library(dplyr)
library(ggplot2)
library(lubridate)
library(purrr)
library(glue)
library(stringr)
## ----warning=F,message=F-------------------------------------------------
NOAA_quakes<-jyjekNOAA::NOAA_quakes
## ----warning=F,message=F,eval=F------------------------------------------
# ?jyjekNOAA::NOAA_quakes
## ----warning=F,message=F-------------------------------------------------
NOAA_quakes%>%
eq_clean_data()%>%
head()
## ----warning=F,message=F-------------------------------------------------
NOAA_quakes%>%
eq_clean_data()%>%
dplyr::filter(COUNTRY %in% c('CHINA','MEXICO')) %>%
dplyr::filter(DATE > '2010-01-01') %>%
ggplot2::ggplot() +
geom_timeline(aes(x = DATE, y = COUNTRY, size = as.numeric(EQ_PRIMARY),
color = as.numeric(TOTAL_DEATHS))) +
guides(size = guide_legend(order=1))+
scale_color_continuous(name = '# deaths') +
scale_size_continuous(name = 'Richter scale value')+ NOAA_thm()
## ----warning=F,message=F-------------------------------------------------
NOAA_quakes%>%
eq_clean_data()%>%
dplyr::filter(COUNTRY %in% c('USA', 'JAPAN')) %>%
dplyr::filter(DATE > '2000-01-01') %>%
ggplot() +
geom_timeline(aes(x = DATE, y = COUNTRY, color = as.numeric(TOTAL_DEATHS),
size = as.numeric(EQ_PRIMARY))) +
geom_timeline_label(aes(x = DATE, y = COUNTRY, magnitude = as.numeric(EQ_PRIMARY),
label = LOCATION_NAME, n_max = 5)) + guides(size = guide_legend(order=1))+
scale_size_continuous(name = 'Richter scale value') +
scale_color_continuous(name = '# of deaths') +
NOAA_thm()
## ----warning=F,message=F-------------------------------------------------
NOAA_quakes%>%
eq_clean_data()%>%
dplyr::filter(COUNTRY == 'MEXICO') %>%
dplyr::filter(lubridate::year(DATE) >= 2000) %>%
dplyr::mutate(popup_text = eq_create_label(.))%>%
eq_map(annot_col = "popup_text")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.