Get data for a single variable from either FRED or World Bank Data, for a given URL or variable code. The function will figure out whether the data is available from FRED or World Bank Data.

get_ecodata_variable(
  varcode,
  varname = NULL,
  frequency = NULL,
  units = NULL,
  recessions = FALSE
)

Arguments

varcode

String that identifies the variable code or URL for the data

varname

Optional, string for the variable name. Default is the code given by the source.

frequency

Optional, string for what frequency to aggregate to. Valid only for FRED data. This parameter is passed to `fredr::fredr()`. The default is no aggregation. - "d" - Daily - "w" - Weekly - "bw" - Biweekly - "m" - Monthly - "q" - Quarterly - "sa" - Semiannual - "a" - Annual - "wem" - Weekly, ending Monday - "wetu" - Weekly, ending Tuesday - "wew" - Weekly, ending Wednesday - "weth" - Weekly, ending Thursday - "wef" - Weekly, ending Friday - "wesa" - Weekly, ending Saturday - "wesu" - Weekly, ending Sunday - "bwew" - Biweekly, ending Wednesday - "bwem" - Biweekly, ending Monday

units

Optional, string indicating the data transformation to make when retrieving the data. This parameter is passed to `fredr::fredr()` and is valid only for FRED data. The default is no transformation. - "lin" - Levels (No transformation) - "chg" - Change - "ch1" - Change from 1 year ago - "pch" - Percent change - "pc1" - Percent change from 1 year ago - "pca" - Compounded annual rate of change - "cch" - Continuously compounded rate of change - "cca" - Continuously compounded annual rate of change - "log" - Natural log

recessions

Logical for whether or not to include a dummy variable identifying a NBER U.S. Recessions. Default = FALSE.

Value

Data frame time series that includes the date and the variable requested. The data frame will also include all relevant meta data describing the data and citing its source.