Description Usage Arguments Examples
Plots "recession bars" on a graph. Note - only really good for plotting one variable.
1 2 | geom_shade(data, variable, date.index = "Week", alpha = 0.2,
overlap = 3.5, fill = "pink")
|
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. |
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.