Skip to content

The goal of bacenR is to provide R functions to download and work with data from the Brazilian Central Bank (Bacen).

Notifications You must be signed in to change notification settings

rtheodoro/bacenR

Repository files navigation

bacenR

CRAN status R-CMD-check Lifecycle: experimental

The goal of bacenR is to provide R functions to download and work with data from the Brazilian Central Bank (Bacen).

The datasets available through bacenR include:

To get data about IPCA, Selic, GDP, Government Debt, and others, check the packages: BacenAPI and rbcb.

Summary

Install

You can install the development version of bacenR like so:

# install.packages("pak") # if you don't have pak installed yet
pak::pak("rtheodoro/bacenR")

Usage

This is a basic example of use:

# Load the package
library(bacenR)

# Download normative legislation related to Credit Cooperatives
normative_data <- get_normative_data(
    terms = c("Cooperativas de Crédito", "Cooperativa de Crédito"), 
    ini_date = "2020-01-01", 
    end_date = Sys.Date()
)

# Download texts of the normative legislation
normative_txt <- get_normative_txt(normative_data)

# Download financial statements of banks and credit cooperatives
get_balance_sheets(
   institution = c("BANCOS", "COOPERATIVAS"),
   months = c(6, 12),
   first_year = 1993,
   final_year = 2023,
   out_dir = "data_raw",
   overwrite = FALSE
)

# Unified treatment of downloaded financial statements
tidy_balance_sheets(
    path_raw = "data_raw", 
    out_dir = "out",
    doc_filter = 4010, 
    save = TRUE
)

# Download list of financial institutions regulated by Bacen
get_institutions(
  institution = c("COOPERATIVAS", "BANCOS"),
  start_date = "202312",
  end_date = "202405",
  out_dir = "data_raw",
  cleanup_zip = TRUE,
  verbose = TRUE
)

# Tidy the institutions data
tidy_institutions(
  path_raw = "data_raw",
  out_dir = "data"
)

To-do

More details about the to-do list can be found in the GitHub project board.

Feel free to contribute to this list by opening issues or pull requests on GitHub!

Author

Ricardo Theodoro:

How to cite

To cite bacenR in publications, please use:

citation("bacenR")
@manual{,
  title = "bacenR: Tools to Access Data from Banco Central do Brasil",
  author = "Ricardo Theodoro",
  year = "2026",
  version = "v0.2.0",
  url = "https://github.com/rtheodoro/bacenR"
}

Support

If this package is useful and saves you time, please consider starring this GitHub repository.

You can also buy me a coffee via PIX.

About

The goal of bacenR is to provide R functions to download and work with data from the Brazilian Central Bank (Bacen).

Topics

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages