View source: R/get_institutions.R
| get_institutions | R Documentation |
This function downloads financial institutions data from the Brazilian Central Bank (Bacen) website for specified institution types and date ranges. The data is downloaded as ZIP files, extracted, and can be optionally cleaned up.
get_institutions(
institution,
years,
months,
out_dir,
cleanup_zip = TRUE,
verbose = TRUE
)
institution |
Character vector. Type(s) of financial institutions to download. Valid options are:
Default is "COOPERATIVAS". Case-insensitive. Check the details on Bacen's website. |
years |
Numeric vector. Year(s) to download, e.g. |
months |
Numeric vector. Month(s) to download, values between 1 and 12,
e.g. |
out_dir |
Character. Directory path where downloaded files will be saved. Default is "data". The directory will be created if it doesn't exist. |
cleanup_zip |
Logical. If TRUE, removes ZIP files after extraction. Default is TRUE. |
verbose |
Logical. If TRUE, displays progress messages and warnings. Default is TRUE. |
The function performs the following steps:
Validates institution types against known valid options
Generates every combination of years x months as year-month strings
Downloads ZIP files for each institution and month from BCB website
Extracts the downloaded ZIP files to the output directory
Optionally removes ZIP files after extraction
Displays progress information if verbose = TRUE
For CONGLOMERADOS, the file suffix on BCB's server changed from the plural
"CONGLOMERADOS" to the singular "CONGLOMERADO" starting in months after 2022
(e.g. .../202208CONGLOMERADOS.zip vs. .../202607CONGLOMERADO.zip). This is
handled internally and is transparent to the caller.
Institution type mappings:
CONGLOMERADOS: Conglomerados
BANCOS: Bancos comerciais, múltiplos e caixa
COOPERATIVAS: Cooperativas de crédito
ADMCONSORCIO: Consórcios administrativos
SOCIEDADES: Bancos de investimentos, desenvolvimento e sociedades corretoras
Invisible NULL. The function is called for its side effects (downloading and extracting files to the specified directory).
https://www.bcb.gov.br/estabilidadefinanceira/relacao_instituicoes_funcionamento
# Download cooperative credit unions data for 2023
get_institutions(
institution = "COOPERATIVAS",
years = 2023,
months = 11:12,
out_dir = tempdir()
)
# Download multiple institution types
get_institutions(
institution = c("BANCOS", "COOPERATIVAS"),
years = 2022,
months = 1:12,
out_dir = tempdir()
)
# Skip downloading, just use existing files
get_institutions(
institution = "BANCOS",
years = 2022,
months = 1:12,
out_dir = tempdir(),
verbose = FALSE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.