geom_shade: Geom for shading graph to highlight periods.

Description Usage Arguments Examples

View source: R/geom_shade.R

Description

Plots "recession bars" on a graph. Note - only really good for plotting one variable.

Usage

1
2
geom_shade(data, variable, date.index = "Week", alpha = 0.2,
  overlap = 3.5, fill = "pink")

Arguments

data

data.table that holds the data

variable

Numeric. Dummy variable, 1 = plot.

date.index

Character. Date index of x, e.g. "Week", need to be of Date class.

alpha

Transparency of bar shades. 1 = opaque, 0 = transparent.

overlap

Numeric. Overlap of the bars, seems to be OK left as 3.5.

fill

Character. Colour for the bars.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x <- data.table::fread(system.file("extdata", "lm.csv", package = "nladwa"))
x <- x[complete.cases(x)]
x[, Week := as.Date(Week)]
x[, dummy := 0]
x[sample(1:nrow(x), 60), dummy := 1]

ggplot() +
  geom_shade(data = x, variable = "dummy", date.index = "Week", alpha = 0.5) +
  geom_line(data = x, aes(x = Week, y = TotalGrossLeads))

warning("This function is only really any good for plotting one variable")

Braja93/braja documentation built on June 1, 2017, 5:19 p.m.