Imports Datasets from BCB (Central Bank of Brazil) using Its Official API

Downloads and organizes datasets using BCB's API < https://www.bcb.gov.br/>. Offers options for caching with the 'memoise' package and , multicore/multisession with 'furrr' and format of output data (long/wide).


The Central Bank of Brazil (BCB) offers access to its SGS system (sistema gerenciador de series temporais) with a official API available here.

Package GetBCB offers a R interface to the API and many other advantages:

  • Use of a caching system with package memoise to speed up repeated requests of data;
  • User can utilize all cores of the machine (parallel computing) when fetching a large batch of time series;
  • Error handling internally. Even if requested series does not exist, the function will still return all results.

Installation

# CRAN (official release) - SOON
install.packages('GetBCBData')

# Github (dev version)
devtools::install_github('msperlin/GetBCBData')

A simple example

library(GetBCBData)
library(tidyverse)

my.countries <- c('Germany', 'Canada', 'USA', 
                  'France', 'Italy', 'Japan')

my.ids <- c(3785:3790)

names(my.ids) <- paste0('Unemp. rate - ', my.countries)

df.bcb <- gbcbd_get_series(id = my.ids ,
                       first.date = '2000-01-01',
                       last.date = Sys.Date(),
                       format.data = 'long',
                       #series.name = 'ABC',
                       use.memoise = TRUE, 
                       cache.path = tempdir(), # use tempdir for cache folder
                       do.parallel = FALSE)

glimpse(df.bcb)

p <- ggplot(df.bcb, aes(x = ref.date, y = value) ) +
  geom_line() + 
  labs(title = 'Unemploymnent Rates Around the World', 
       subtitle = paste0(min(df.bcb$ref.date), ' to ', max(df.bcb$ref.date)),
       x = '', y = 'Percentage*100') + facet_wrap(~series.name)
  

print(p)

News

Version 0.5 (2019-04-15)

  • First release

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("GetBCBData")

0.5 by Marcelo Perlin, a month ago


https://github.com/msperlin/GetBCBData/


Report a bug at https://github.com/msperlin/GetBCBData/issues


Browse source code at https://github.com/cran/GetBCBData


Authors: Marcelo Perlin [aut, cre]


Documentation:   PDF Manual  


GPL-2 license


Imports stringr, stats, RCurl, lubridate, readr, utils, curl, dplyr, future, furrr, jsonlite, memoise, purrr

Suggests knitr, rmarkdown, testthat, ggplot2, tidyverse


See at CRAN