A simple R package for downloading a variable from the FRED database for multiple countries.
For series that are available across multiple countries, FRED denotes each series with a common ID scheme. This includes a prefix, the country's ISO two letter country code, and a suffix. You can find the prefix and suffix on each series' data page on FRED.
For example, this symbol is for Irish central government debt, total (% of GDP): DEBTTLIEA188A. It has the prefix DEBTTL
and suffix A188A
. Ireland's ISO two letter country code is IE
.
In the following example we download the central government debt data for Ireland and Japan (whose ISO2C code is JP
):
# Download Central government debt, total (% of GDP) for Ireland and Japan
fred_loop(prefix = 'DEBTTL', suffix = 'A188A', iso2c = c('IE', 'JP'),
var_name = 'pubdebtgdp_cent_fred')
You can also download a single series using the single_symbol
argument. For example:
# Download single series (US Federal Funds Rate)
fred_loop(single_symbol = 'FEDFUNDS')
The package is not on CRAN so install using:
devtools::install_github('christophergandrud/fredr')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.