geom_timeline: Function for plotting timeline of earthquake data

Description Usage Arguments Value Examples

Description

This function (geom_timeline) subsets the data to values between xmin and xmax using the filter_ function from the dplyr package (filter_). Uses the layer function from the ggplot2 package (layer) to call the geomtimeline geom and use it on the data.

Usage

1
2
3
geom_timeline(mapping = NULL, data = NULL, stat = "identity",
  position = "identity", na.rm = FALSE, show.legend = NA,
  inherit.aes = TRUE, ...)

Arguments

mapping

Set of aesthetic mappings created by aes or aes_; If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot; You must supply mapping if there is no plot mapping; Required aes: Date field - x, lowest date to include - xmin, highest date to include - xmax; Default aes: Group variable where separate timelines should be created for each unique value - y; variable where values distinguished by point outline colour - colour; variable where values distinguished by point fill colour - fill, variable where values distinguished by point size - size; transparency of points - alpha, shape of points - shape, width of border to points - stroke.

data

The data to be displayed in this layer. There are three options: If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot. A data.frame, or other object, will override the plot data; All objects will be fortified to produce a data frame; See fortify for which variables will be created; A function will be called with a single argument, the plot data; The return value must be a data.frame, and will be used as the layer data.

stat

Statistical transformation to use on the data.

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

na.rm

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

show.legend

Logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped; FALSE never includes, and TRUE always includes.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them; This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders.

...

Other arguments passed on to layer; These are often aesthetics, used to set an aesthetic to a fixed value, like color = "red" or size = 3; They may also be parameters to the paired geom/stat.

Value

A timeline showing eathquake sizes and intensities between specified dates.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## Not run: 
eq_clean_loc_tl <- ggplot(data = eq_clean_loc) +
geom_timeline(aes(x = DATE,
		     xmin = as.Date("2000-01-01"),
	     xmax = as.Date("2015-12-31"),
	     size = EQ_PRIMARY,
           	     fill = TOTAL_DEATHS          		
)) +
labs(size = "Richter scale value", fill = "# deaths") +
theme(legend.position="bottom") 

eq_clean_loc_tl <- ggplot(data = eq_clean_loc) +
geom_timeline(aes(x = DATE,
	     xmin = as.Date("2000-01-01"),
	     xmax = as.Date("2015-12-31"),
	     y = COUNTRY,
	     size = EQ_PRIMARY,
          	     fill = TOTAL_DEATHS          		
)) +
labs(size = "Richter scale value", fill = "# deaths") +
theme(legend.position="bottom") 

eq_clean_loc_tl <- ggplot(data = subset(eq_clean_loc, COUNTRY %in% c("USA" , "CHINA"))) +
geom_timeline(aes(x = DATE,
	     xmin = as.Date("2000-01-01"),
	     xmax = as.Date("2015-12-31"),
	     y = COUNTRY,
	     size = EQ_PRIMARY,
          	     fill = TOTAL_DEATHS          		
)) +
labs(size = "Richter scale value", fill = "# deaths") +
theme(legend.position="bottom")

## End(Not run)

drsmd23/Eq documentation built on May 14, 2019, 10:33 a.m.