geom_timeline: A ggplot2 layer: 'geom_timeline()' function

Description Usage Arguments Value Examples

View source: R/geom_timeline.R

Description

Construct a regular function/layer to plot a timeline with the earthquakes of a given country that is added to a plot created with ggplot() function.

The geom_timeline() function is a wrapper to the layer function for the 'GeomTimeline' class.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
geom_timeline(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE,
  ...
)

Arguments

mapping

aesthetic mappings created by aes

data

is the data frame that contains the earthquake's data

stat

layer's statistical transformation

position

position adjustment function

na.rm

remove the NA values from the data frame

show.legend

layer's legend

inherit.aes

will indicate the default aesthetics overridng

...

layer's other arguments

Value

a plot timeline with earthquakes of a given country or list of countries.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
filename <- system.file("extdata", "signif.txt", package = "earthquakes")
library(readr)
eq_data_raw <- readr::read_delim(file = filename, delim = "\t")
eq_data <- eq_clean_data(eq_raw = eq_data_raw)
library(dplyr)
library(ggplot2)
library(ggthemes)
eq_data %>%
    dplyr::filter(DATE >= "1995-01-01" &
                      DATE <= "2018-01-01" &
                      COUNTRY %in% c("USA","ITALY","MEXICO")) %>%
    ggplot(aes(x = DATE,
               y = COUNTRY,
               colour = DEATHS,
               size = EQ_PRIMARY)) +
    geom_timeline() +
    theme_tufte() +
    theme(legend.position = "right")

## End(Not run)

raggichr/earthquakes documentation built on June 25, 2020, 5:45 p.m.