diff --git a/.Rbuildignore b/.Rbuildignore index 2386bd0..51c8e5b 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -7,3 +7,4 @@ cache_json R/pillar3_backend.R ^codecov\.yml$ ^data-raw$ +^vignettes/articles$ diff --git a/.gitignore b/.gitignore index 3f9a5e9..8939818 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ nbs inst/doc *.csv *.RDS +vignettes/articles/cache_json diff --git a/DESCRIPTION b/DESCRIPTION index 70be218..72fb71c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: brazilianbanks Type: Package Title: Data on Brazilian banks and other regulated financial institutions -Version: 0.0.3 +Version: 0.0.4 Author: Douglas Kiarelly Godoy de Araujo Maintainer: Douglas Kiarelly Godoy de Araujo Description: A user-friendly interface to official datasets of bank-level variables diff --git a/R/data.R b/R/data.R index 7aefeae..38b47b9 100644 --- a/R/data.R +++ b/R/data.R @@ -9,3 +9,18 @@ #' #' @source https://www3.bcb.gov.br/ifdata/ "brazilian_banks_201703_202112" + +#' Brazilian banks and other financial institutions: 2017 Q1 onwards to the most recent quarter +#' +#' This data is updated frequently to contain the most up-to-date data. For a smaller version +#' that includes data only up to 2021 Q4, please see `brazilian_banks_201703_202112`. +#' +#' Accounting, risk and other information for banks and +#' other financial institutions in Brazil, from the +#' 'IF.data' system of the Central Bank of Brazil. +#' +#' @format ## `brazilian_banks_201703_onwards` +#' A tibble with 26,885 rows and 426 columns +#' +#' @source https://www3.bcb.gov.br/ifdata/ +"brazilian_banks_201703_onwards" diff --git a/README.md b/README.md index a598c14..8113643 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,19 @@ devtools::install_github("dkgaraujo/brazilianbanks") ``` ## Usage + +### Bank-level information + +The `brazilianbanks` package already includes off-the-shelf two datasets of banks and other financial institutions' accounting, risk and other information. One such dataset includes all information from 2017 Q1 up to the most recent quarter: `brazilian_banks_201703_onwards`. A shorter version of this dataset covers the period of 2017 Q1 to 2021 Q4: `brazilian_banks_201703_202112`. + +``` +library(brazilianbanks) + +brazilian_banks_201703_onwards +``` + +Using these pre-loaded datasets is usually a quicker alternative to `get_bank_stats()`, the main function to retrieve data in a more customised way. + The function `all_available_quarters()` returns a vector with all the quarters for which there is available data. I suggest you run this function first, in particular to check what the most recent quarter is. If you are interested in bank-level variables (eg, accounting or credit risk figures), the main function is `get_bank_stats()`. It returns a tibble data frame with the panel data: @@ -29,7 +42,7 @@ bank_df <- get_bank_stats(yyyymm_start = 201903, yyyymm_end = max(quarters)) The initial and final quarters (arguments `yyyymm_start` and `yyyymm_end` respectively) are defined by the user according to the YYYYMM format, ie March 2014 is 201403. Note that the code chunk above uses the most recent available quarter as the final quarter for data download. -> Note that the `brazilianbanks` package already embeds a dataset variable of banks and other financial institutions' accounting, risk and other information for the period of 2017 Q1 to 2021 Q4: `brazilian_banks_201703_202112`. If you are looking to get familiar with the dataset and the time frame of this variable is suitable for you, using it is a quicker alternative to `get_bank_stats()`. +### Banking statistics at the municipality level If your focus is on municipality-level banking statistics, the main function is `get_municipal_stats()`. It returns a tibble data frame with bank balance sheet and financial statement variables at the municipal level, at a monthly frequency: diff --git a/data-raw/brazilian_banks_201703_202112.R b/data-raw/brazilian_banks_201703_202112.R index ad14cd0..f63387e 100644 --- a/data-raw/brazilian_banks_201703_202112.R +++ b/data-raw/brazilian_banks_201703_202112.R @@ -9,3 +9,13 @@ brazilian_banks_201703_202112 <- get_bank_stats(yyyymm_start = 201703, verbose = TRUE) usethis::use_data(brazilian_banks_201703_202112, overwrite = TRUE) + +brazilian_banks_201703_onwards <- get_bank_stats(yyyymm_start = 201703, + yyyymm_end = tail(all_available_quarters(), n = 1), + banks_only = FALSE, + adjust_income_data = TRUE, + include_growthrate = FALSE, + cache_json = TRUE, + verbose = TRUE) + +usethis::use_data(brazilian_banks_201703_onwards, overwrite = TRUE) diff --git a/data/brazilian_banks_201703_onwards.rda b/data/brazilian_banks_201703_onwards.rda new file mode 100644 index 0000000..25268f8 Binary files /dev/null and b/data/brazilian_banks_201703_onwards.rda differ