knitr::opts_chunk$set( collapse = TRUE, results = 'hold', comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The Central Bank of Brazil (BCB) offers access to its SGS system (sistema gerenciador de series temporais) with a official API available here.
Package GetBCBData offers a R interface to the API and many other advantages:
memoise
to speed up repeated requests of data;# CRAN (official release) install.packages('GetBCBData') # Github (dev version) devtools::install_github('msperlin/GetBCBData')
library(GetBCBData) library(ggplot2) my.id <- c('Selic' = 432) df.bcb <- gbcbd_get_series(my.id, cache.path = tempdir()) head(df.bcb) p <- ggplot(df.bcb, aes(x = ref.date, y = value) ) + geom_line() + labs(title = 'SELIC', subtitle = paste0(min(df.bcb$ref.date), ' to ', max(df.bcb$ref.date)), x = 'Time', y = 'Percentage*100') + theme_light() print(p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.