The cmapplot package contains an internal dataset recessions of all recessions in American history as recorded by the National Bureau of Economic Research (NBER). However, users may need to replace the built-in data, such as in the event of new recessions and/or changes to the NBER consensus on recession dates. This function fetches and interprets this data from the NBER website.

update_recessions(url = NULL, quietly = FALSE)

Arguments

url

Char, the web location of the NBER machine-readable CSV file. The default, NULL, uses the most recently identified URL known to the package development team, which appears to be the most stable location for updates over time.

quietly

Logical, suppresses messages produced by utils::download.file.

Value

A data frame with the following variables:

  • start_char, end_char: Chr. Easily readable labels for the beginning and end of the recession.

  • start_date, end_date: Date. Dates expressed in R datetime format, using the first day of the specified month.

  • ongoing: Logical. Whether or not the recession is ongoing as of the latest available NBER data.

Examples

recessions <- update_recessions()
#> Warning: cannot open URL 'http://data.nber.org/data/cycles/cycle%20dates%20pasted.csv': HTTP status was '404 Not Found'
#> WARNING: Fetch or processing failed. `NULL` returned.

# package maintainers can update the internal dataset from within
# package by running the following code:
if (FALSE) { # \dontrun{
  recessions <- update_recessions()
  usethis::use_data(recessions, internal = TRUE, overwrite = TRUE)
} # }