nber_recession_ggplot: A convenient wrapper to plot shadded areas in ggplot2 in...

Description Usage Arguments Value Note See Also Examples

Description

A convenient wrapper to plot shadded areas in ggplot2 in periods of recession

Usage

1
nber_recession_ggplot(periodicity, start_date, end_date, alpha = 0.3)

Arguments

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 Dates format

end_date

The ending date in Dates format

alpha

The transparency. Defaults to 0.3

Value

This should be used with a ggplot. Will shade the areas where there were recessions

Note

This basically call geom_rect from ggplot2 using data that was loaded and cutted with recession_dates_ggplot

See Also

recession_dates_ggplot

Examples

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])

danmrc/recessionR documentation built on May 12, 2019, 5:16 p.m.