knitr::opts_chunk$set(
  collapse = TRUE,
  message = FALSE,
  warning = FALSE,
  comment = "#>",
  fig.path = "README-"
)

library(FromQuandl)
library(Quandl)
library(ggplot2)
library(dplyr)
library(ggthemes)
Quandl.api_key("wNTJQSHWqSsKsDQprJhb")

FromQuandl

Travis build status AppVeyor build status R-CMD-check Codecov test coverage

The goal of FromQuandl is to easy the search, download and data preprocessing steps that often happens when using the Quandl package in R.

Currently supports functions for IMF, World Bank and Yale Department of Economics datasets.

Installation

You can install FromQuandl from github with:

# install.packages("devtools")
devtools::install_github("Reckziegel/FromQuandl")

Examples

Suppose you would like to download the Current Account Balance (as % of GDP) for all countries of a specific region or with similar economic characteristics, like the G7. Use the fq_imf_search() function to discover the Current Account code in Quandl.

fq_imf_search('account')

Next use fq_imf() to download and plot the data.

ca <- fq_imf(countries = 'g7', indicators = 'BCA_NGDPD', start_date = '2005-01-01')
ca

ca %>%
  ggplot(aes(x = date, y = value, color = country)) + 
  geom_line(size = 1, show.legend = FALSE) + 
  geom_hline(aes(yintercept = 0), color = 'red', linetype = 'dashed', alpha = 0.3) +
  facet_wrap(~country, scale = "free_y") +
  labs(title    = "Current Account Balance (% of GDP)",
       subtitle = "G7 Countries From 2005-01-01 through 2020-12-01",
       caption  = "Source: International Monetary Found (IMF), Quandl.com.") +
  theme_fivethirtyeight() +
  scale_color_gdocs()

The result is a tibble that it's ready to be used in ggplot2.

There is no need to restrict the download to only one indicator. The indicators argument supports lists and vectors of strings as well, but be aware that may be safe using Quandl.api_key() if you want to access several time series at once.

As a second example imagine that you want to download the rate of change in poverty statistics from the World Bank for all countries in the Commonwealth of Independent States. Simply run

#library(FromQuandl)

# get poverty codes
poverty_data <- fq_wb_search('poverty')

# download data
fq_wb(countries = 'cis', indicators = poverty_data$code, transform = 'rdiff') 

The data is tidy and ready to be used with the %>% operator.

Additional information about the fq_imf(), fq_wb() and fq_yale() can be found at the package documentation.



Reckziegel/FromQuandl documentation built on Jan. 2, 2021, 9:20 p.m.