brfinance 📊🇧🇷

CRAN Status License: MIT R-CMD-check Downloads Downloads GitHub stars GitHub forks

Overview

The brfinance package simplifies access to official Brazilian macroeconomic data from reliable institutions such as the Central Bank of Brazil (BCB) and the IBGE. It is designed to make it easier to collect, organize, and visualize key indicators like inflation, interest rates, and unemployment, directly from R.

Installation

install.packages("brfinance")

# Or development version from GitHub
install.packages("devtools")
devtools::install_github("efram2/brfinance")

library(brfinance)

Quick Start

library(brfinance)

# Download inflation data for 2023
inflation <- get_inflation_rate("2023-01-01")
head(inflation)

# Retrieve SELIC rate from 2020 to 2024
selic <- get_selic_rate(2020, 2024)
head(selic)

# Retrieve unemployment data
unemployment <- get_unemployment(2020, 2024)
head(unemployment)

Language Support

All functions support both English and Portuguese through the language parameter:

About the data

All data used in brfinance is retrieved from official Brazilian institutions:

The package aims to simplify the access and visualization of key Brazilian macroeconomic indicators, especially for researchers, students, and analysts who work with national economic data. # Functions Overview

1. Inflation Analysis

get_inflation_rate()

Downloads monthly IPCA inflation data from the Central Bank of Brazil.

Parameters

Usage

devtools::install_github("efram2/brfinance")
library(brfinance)

# Complete data (default)
inflation <- get_inflation_rate()

# Specific period in English
inflation_eng <- get_inflation_rate(
  start_date = "2020-01-01",
  end_date = "2024-12-01",
  language = "eng"
)

# Portuguese version
inflation_pt <- get_inflation_rate(
  start_date = "2020-01-01",
  language = "pt"
)

2. Selic and Interest Rates

get_selic_rate()

Downloads daily SELIC rate from the Central Bank of Brazil.

Parameters

Usage

library(brfinance)

# English version
selic_eng <- get_selic_rate(2020, 2024)
head(selic_eng)

# Portuguese version
selic_pt <- get_selic_rate(2020, 2024, language = "pt")
head(selic_pt)

plot_selic_rate()

Creates a time series plot of the SELIC rate.

Parameters

Usage

# Get data
selic_data <- get_selic_rate(2020, 2024)

# Create plot
selic_plot <- plot_selic_rate(selic_data, language = "eng")
print(selic_plot)

# Portuguese version
selic_data_pt <- get_selic_rate(2000, 2005, language = "pt")
selic_plot_pt <- plot_selic_rate(selic_data_pt, language = "pt")
print(selic_plot_pt)

3. Unemployment Data

get_unemployment()

Retrieves Brazil’s quarterly unemployment rate from IBGE’s PNAD Contínua.

Parameters

Usage

library(brfinance)

# English version
unemp_eng <- get_unemployment(2018, 2024, language = "eng")
head(unemp_eng)

# Portuguese version
unemp_pt <- get_unemployment(2018, 2024, language = "pt")
head(unemp_pt)

plot_unemployment()

Generates a line chart of Brazil’s unemployment rate.

Parameters

Usage

# English
unemp_data <- get_unemployment(2020, 2024)
unemp_plot <- plot_unemployment(unemp_data, language = "eng")
print(unemp_plot)

# Portuguese
unemp_data2 <- get_unemployment(2020, 2024, language = "pt")
unemp_plot_pt <- plot_unemployment(unemp_data2, language = "pt")
print(unemp_plot_pt)

Contribution

Suggestions, feature requests, and pull requests are welcome!