Learn R Programming

imfr (version 0.1.9.1)

imf_data: Download a data from the IMF

Description

Download a data from the IMF

Usage

imf_data(
  database_id,
  indicator,
  country = "all",
  start = 2000,
  end = current_year(),
  freq = "A",
  return_raw = FALSE,
  print_url = FALSE,
  times = 3
)

Arguments

database_id

character string database ID. Can be found using imf_ids.

indicator

character string or character vector of indicator IDs. These can be found using imf_codes.

country

character string or character vector of ISO two letter country codes identifying the countries for which you would like to download the data.See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2. If country = 'all' then imf_data will attempt to download all available countries.

start

year for which you would like to start gathering the data.

end

year for which you would like to end gathering the data.

freq

character string indicating the series frequency. With 'A' for annual, 'Q' for quarterly, and 'M' for monthly.

return_raw

logical. Whether to return the data as an unprocessed list.

print_url

logical. Whether to print the URL used in the API call. Can be useful for debugging.

times

numeric. Maximum number of requests to attempt.

Value

If return_raw = FALSE then a data frame with just the requested data series are returned. If return_raw = TRUE then the raw data list is returned. This can include additional information about the series.

Examples

Run this code
# NOT RUN {
# Download Real Effective Exchange Rate (CPI base) for the UK and China
# at an annual frequency
real_ex <- imf_data(database_id = 'IFS', indicator = 'EREER_IX',
               country = c('CN', 'GB'), freq = 'A')

# }
# NOT RUN {
# Also download Interest Rates, Lending Rate, Percent per annum
ex_interest <- imf_data(database_id = 'IFS',
                         indicator = c('FILR_PA', 'EREER_IX'),
                         freq = 'M')
# }

Run the code above in your browser using DataLab