An Interface to IMF (International Monetary Fund) Data

Provides low-level access to the International Monetary Fund Statistical Data and Metadata eXchange ('SDMX') 3.0 API, available at < https://data.imf.org/>, and a concise workflow for discovering datasets, inspecting dimensions, and downloading observations as tidy data frames.


imf.data

PackageVersion R-CMD-check downloads

imf.data provides an R interface to the IMF SDMX 3.0 API. It supports discovering datasets, inspecting their dimensions, and downloading observations as tidy data frames. Raw SDMX responses are also available for advanced use.

Installation

Install imf.data from CRAN:

install.packages("imf.data")

Install the development version from GitHub:

pak::pak("pedrobtz/imf.data")

Quick start

library(imf.data)

# Discover IMF Statistics Department datasets
datasets <- list_datasets("IMF.STA")
datasets[datasets$id == "CPI", ]
# Inspect a dataset's key dimensions
list_dimensions("CPI")
# Find valid frequency codes for US CPI data
list_dimension_values(
  "CPI",
  "FREQUENCY",
  filters = list(COUNTRY = "USA")
)
# Download the latest monthly headline CPI observations
cpi <- get_data(
  "CPI",
  filters = list(
    COUNTRY = c("USA", "CAN"),
    INDEX_TYPE = "CPI",
    COICOP_1999 = "_T",
    TYPE_OF_TRANSFORMATION = "IX",
    FREQUENCY = "M"
  ),
  last_n_obs = 12,
  attributes = "STATUS"
)
cpi

get_data() returns one row per observation. Dimension and time columns are character vectors, OBS_VALUE is numeric, and requested SDMX attributes are included as additional columns.

Raw SDMX access

raw <- sdmx_data(
  "CPI",
  key = "USA.CPI._T.IX.M",
  last_n_obs = 2
)

See vignette("getting-started") for a complete workflow.

Proxy configuration

httr2 respects standard proxy environment variables such as HTTPS_PROXY and NO_PROXY. A proxy can also be configured specifically for imf.data:

set_imf_proxy(
  "http://proxy.example.com",
  port = 8080,
  username = Sys.getenv("PROXY_USER"),
  password = Sys.getenv("PROXY_PASSWORD")
)

list_datasets("IMF.STA")
clear_imf_proxy()

The package-specific configuration applies to all raw and tidy API functions for the remainder of the R session, until clear_imf_proxy() is called.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("imf.data")

0.2.0 by Pedro Baltazar, 4 months ago


https://pedrobtz.github.io/imf.data/


Report a bug at https://github.com/pedrobtz/imf.data/issues


Browse source code at https://github.com/cran/imf.data


Authors: Pedro Baltazar [aut, cre, cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports httr2, tibble

Suggests knitr, rmarkdown, testthat, vcr


See at CRAN