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

  options(warn=-1)
)
library(magrittr)
library(dplyr)
library(readr)
library(kableExtra)
library(msdr)
library(ggplot2)

Table of Contents

1. Introduction {#intro}

The geom_timeline_label is a complementary geom to aggregate notations to the geom_timeline. Using this geom you can add labels to the n_max most deadly earthquake. The configuration is almost the same of geom_timeline.

Example 1 {#example_1}

Let's plot the earthquake from 1900 to 2000, which occured in CHINA and TURKEY.

# 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 the data and filtering.
df %>% 
       eq_clean_data() %>%

              filter(COUNTRY %in% c('CHINA','TURKEY'),
                     YEAR >= 1900 &
                     YEAR <= 2000) %>%
              # Creating a ggplot object
              ggplot() + 
                     # Using the new Geom
                     geom_timeline(aes(x     = DATE,
                                       y     = COUNTRY,
                                       size  = EQ_PRIMARY,
                                       color = TOTAL_DEATHS)) +

                            # Adding notation.
                            geom_timeline_label(aes(x = DATE,
                                                    y = COUNTRY,
                                                    mag = EQ_PRIMARY,
                                                    label = LOCATION,
                                                    n_max = 10)) + 

                                   # Adding theme.
                                   theme_msdr() + 
                                          # Editing the legends' titles 
                                          labs(size = "Richter scale value",
                                               color = "# deaths")


nandinigntr/MSDR documentation built on Jan. 1, 2021, 11:32 a.m.