--- title: "Getting Started" author: "Marcelo Perlin" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Getting Started} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ## Motivation The Central Bank of Brazil (BCB) offers access to its SGS system (sistema gerenciador de series temporais) with a official API available [here](http://www.bcb.gov.br/?sgs). Package GetBCBData offers a R interface to the API and many other advantages: - 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. ## A simple example Let's have a look at the interest rate in Brazil. After searching for the ids in the [SGS system](http://www.bcb.gov.br/?sgs), we find that the daily SELIC rate is 432. Now, lets download the data with `GetBCBData`: ```{r, message=FALSE} library(GetBCBData) library(dplyr) library(ggplot2) my.id <- c(selic = 432) df.bcb <- gbcbd_get_series(id = my.id , first.date = '2000-01-01', last.date = Sys.Date(), format.data = 'long', 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/100) ) + geom_line() + labs(title = 'Selic Rate', subtitle = paste0(min(df.bcb$ref.date), ' to ', max(df.bcb$ref.date)), x = '', y = 'Interest Rate') + theme_light() print(p) ```