knitr::opts_chunk$set( collapse = TRUE, comment = "#>", options(warn=-1) )
library(magrittr) library(dplyr) library(readr) library(kableExtra) library(msdr) library(ggplot2)
This function acts behind the scenes creating all the visuals to be displayed by the geom_timeline
.
Although this function is wrapped by the geom_timeline
you can still use it by the use of ggplot2::layer
.
Using ggplot2::layer
to plot the visuals of GeomTimeline
.
# Path to the raw data. raw_data_path <- system.file("extdata", "signif.txt", package = "msdr") # Loading the dataset of Earthquake. df <- readr::read_delim(file = raw_data_path, delim = '\t', col_names = TRUE, progress = FALSE, col_types = readr::cols()) # Cleaning and Creating LOCATION column. df_clean <- df %>% eq_clean_data() %>% filter(COUNTRY %in% c('CANADA','USA','MEXICO')) # Plotting using layer. ggplot2::ggplot() + ggplot2::layer(geom = GeomTimeline, mapping = aes(x = DATE, y = COUNTRY, size = EQ_PRIMARY, color = TOTAL_DEATHS), data = df_clean, stat = 'identity', position = 'identity', show.legend = NA, inherit.aes = TRUE, params = list(na.rm = FALSE)) + theme_msdr()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.