Description Usage Arguments Value Note See Also Examples
A convenient wrapper to plot shadded areas in ggplot2 in periods of recession
1 | nber_recession_ggplot(periodicity, start_date, end_date, alpha = 0.3)
|
periodicity |
What is the periodicity of data used. Only accepts (q)uartely or (m)onthly. You can use the whole word or only the first letter |
start_date |
The start date in |
end_date |
The ending date in |
alpha |
The transparency. Defaults to 0.3 |
This should be used with a ggplot. Will shade the areas where there were recessions
This basically call geom_rect
from ggplot2 using data that was loaded and cutted with recession_dates_ggplot
1 2 3 4 5 6 7 | x <- rnorm(500)
today <- Sys.Date()
datess <- rev(seq(today,length.out = 500, by = "-1 month"))
ddata <- data.frame(Dates = datess, x = x)
ggplot() + geom_line(data = ddata, aes(Dates,x)) + nber_recession_ggplot("m",start_date = ddata[1,1],end_date = ddata[500,1])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.