eq_timeline: Produce Earthquake Timeline Plots

Description Usage Arguments Details Value Examples

View source: R/eq_timeline.R

Description

eq_timeline is a function to easily create a timeline plot with or without labels using NOAA Significant Earthquake data.

Usage

1
2
eq_timeline(df, countries = "USA", date_min = "2000-01-01",
  date_max = "2018-01-01", label_n = 0)

Arguments

df

The cleaned earthquake data to timeline. See eq_load_clean_data for more information.

countries

Default USA. May be a single country or a character vector of countries (countries stacked on y-axis).

date_min

Default '2000-01-01'. Minimum date for timeline in YYYY-mm-dd format. May pass in a Date, a POSIXct, or character vector which can be coerced to a Date.

date_max

Default '2018-01-01'. Maximum date for timeline in YYYY-mm-dd format. May pass in a Date, a POSIXct, or character vector which can be coerced to a Date.

label_n

Default 0. If label_n == 0, no labels are printed on the timeline. Otherwise, the number of labels specified as the value for this parameter are printed. Suggest keeping this number less than or equal to 10.

Details

This function is a wrapper function that makes it easy to create a timeline plot of the NOAA Significant earthquakes for a given country or countries. It also allows the user to specify (or not!) the number of earthquakes to label. This function makes it easy to use the recommended defaults for geom_timeline, geom_timeline_label, and theme_eq. The benefit of using this function is that it saves the user a significant amount of typing and data filtering, though it gives up control in specifics of how the timelines are displayed.

Value

A ggplot2 object, showing the earthquake timeline.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# An example with a single country and no labels, showing two
# different classes of date* parameters being passed in.
library(ggplot2); library(dplyr)
quakes <- eq_load_clean_data()
quakes %>% eq_timeline(countries = 'USA', date_min = as.Date('1995-01-01'),
                      date_max = as.POSIXct('2015-01-01'), label_n = 0)

  
# An example with multiple countries and 5 labels per country.
quakes <- eq_load_clean_data()
quakes %>% eq_timeline(countries = c('JAPAN', 'INDONESIA', 'HAITI'),
                      date_min = '2000-01-01', date_max = '2017-01-01',
                      label_n = 5)

DYZI/Earthquake documentation built on May 7, 2019, 6:54 p.m.