diff --git a/.Rbuildignore b/.Rbuildignore
index 4ab2bf9..ae9bc16 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -9,3 +9,5 @@
^\.github$
^doc$
^Meta$
+^\.Rhistory$
+^\.RData$
diff --git a/DESCRIPTION b/DESCRIPTION
index 31895ea..3fdaa16 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: brfinance
Title: Simplified Access to Brazilian Financial and Macroeconomic Data
-Version: 0.5.0.900
+Version: 0.6.0.900
Authors@R:
person(given = "João Paulo", family = "dos Santos Pereira Barbosa", email = "joao.31582129@gmail.com",role = c("aut", "cre"))
Description: It offers simplified access to Brazilian macroeconomic and financial indicators selected from official sources, such as the 'IBGE' (Brazilian Institute of Geography and Statistics) via the 'SIDRA' API and the 'Central Bank of Brazil' via the 'SGS' API. It allows users to quickly retrieve and visualize data series such as the unemployment rate and the Selic interest rate. This package was developed for data access and visualization purposes, without generating forecasts or statistical results. For more information, see the official APIs: and .
diff --git a/NAMESPACE b/NAMESPACE
index 779142d..96e80f1 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -6,6 +6,9 @@ export(get_gdp_growth)
export(get_inflation_rate)
export(get_selic_rate)
export(get_unemployment)
+export(plot_cdi_rate)
+export(plot_exchange_rate)
+export(plot_inflation_rate)
export(plot_selic_rate)
export(plot_series_comparison)
export(plot_unemployment)
diff --git a/R/get_cdi_rate.R b/R/get_cdi_rate.R
index 8bb651a..0ab1ebb 100644
--- a/R/get_cdi_rate.R
+++ b/R/get_cdi_rate.R
@@ -19,9 +19,12 @@
#' @param labels Logical indicating whether to add variable labels using the `labelled`
#' package. Labels provide descriptive text for each column when available.
#'
-#' @return A data.frame with CDI rate. Columns depend on the `language` parameter:
-#' - English (`language = "eng"`): `date` (Date), `cdi_rate` (numeric, % per year)
-#' - Portuguese (`language = "pt"`): `data_referencia` (Date), `taxa_cdi` (numeric, % ao ano)
+#' @return A data.frame with columns:
+#' \describe{
+#' \item{date}{Reference date}
+#' \item{value}{Daily CDI rate (% per day)}
+#' \item{value_annualized}{Annualized CDI rate (% per year, 252 business days)}
+#' }
#'
#' @note
#' **Series information**: This function uses SGS series 12, which represents the
@@ -79,7 +82,7 @@ get_cdi_rate <- function(start_date = NULL,
# === FUNCTION BODY ===
# Declare global variables for dplyr operations
- value <- cdi_rate <- NULL
+ value <- cdi_rate <- value_annualized <- NULL
# Use internal function to download data (SGS series 12 = CDI rate)
data <- .get_sgs_series(
@@ -91,33 +94,31 @@ get_cdi_rate <- function(start_date = NULL,
# Process the data
data <- data |>
dplyr::arrange(date) |>
+ dplyr::mutate(
+ value_annualized = ((1+value/100)^252-1)*100
+ ) |>
dplyr::select(
date,
- cdi_rate = value # Rename for clarity
+ value,
+ value_annualized
)
- # Translation to Portuguese if needed
- if (language == "pt") {
- data <- data |>
- dplyr::rename(
- data_referencia = date,
- taxa_cdi = cdi_rate
- )
- }
-
- # Add labels if requested and package is available
+ # === VARIABLE LABELS ===
if (isTRUE(labels) && requireNamespace("labelled", quietly = TRUE)) {
+
if (language == "pt") {
data <- labelled::set_variable_labels(
data,
- data_referencia = "Data de referencia",
- taxa_cdi = "Taxa CDI (% ao ano) - Certificado de Deposito Interbancario"
+ date = "Data de referencia",
+ value = "Taxa CDI diaria (% ao dia)",
+ value_annualized = "Taxa CDI anualizada (% ao ano, 252 dias uteis)"
)
} else {
data <- labelled::set_variable_labels(
data,
date = "Reference date",
- cdi_rate = "CDI rate (% per year) - Interbank Deposit Certificate"
+ value = "Daily CDI rate (% per day)",
+ value_annualized = "Annualized CDI rate (% per year, 252 business days)"
)
}
}
diff --git a/R/get_exchange_rate.R b/R/get_exchange_rate.R
index 92871a6..177f42f 100644
--- a/R/get_exchange_rate.R
+++ b/R/get_exchange_rate.R
@@ -67,6 +67,13 @@ get_exchange_rate <- function(start_date = NULL,
stop("'labels' must be a single logical value (TRUE or FALSE)", call. = FALSE)
}
+ # Set default start_date if NULL (last 30 days by default for CDI)
+ if (is.null(start_date)) {
+ start_date <- Sys.Date() - 30 # Last 30 days
+ }
+
+ # === FUNCTION BODY ===
+
# Set default start_date if NULL (last 30 days by default for exchange rate)
if (is.null(start_date)) {
start_date <- Sys.Date() - 30 # Last 30 days
@@ -87,31 +94,23 @@ get_exchange_rate <- function(start_date = NULL,
dplyr::arrange(date) |>
dplyr::select(
date,
- exchange_rate = value # Rename for clarity
+ value
)
- # Translation to Portuguese if needed
- if (language == "pt") {
- data <- data |>
- dplyr::rename(
- data_referencia = date,
- taxa_cambio = exchange_rate
- )
- }
-
- # Add labels if requested and package is available
+ # === VARIABLE LABELS ===
if (isTRUE(labels) && requireNamespace("labelled", quietly = TRUE)) {
+
if (language == "pt") {
data <- labelled::set_variable_labels(
data,
- data_referencia = "Data de referencia",
- taxa_cambio = "Taxa de cambio (R$/US$) - comercial, venda"
+ date = "Data de referencia",
+ value = "Taxa de cambio (R$/US$) - comercial, venda"
)
} else {
data <- labelled::set_variable_labels(
data,
date = "Reference date",
- exchange_rate = "Exchange rate (R$/US$) - commercial, selling"
+ value = "Exchange rate (R$/US$) - commercial, selling"
)
}
}
diff --git a/R/get_gdp_growth.R b/R/get_gdp_growth.R
index 9d8d9dd..f3ea893 100644
--- a/R/get_gdp_growth.R
+++ b/R/get_gdp_growth.R
@@ -55,85 +55,55 @@ get_gdp_growth <- function(start_date = "2000-01-01",
language = "eng",
labels = TRUE) {
- # Validate 'language' parameter
+ # === PARAMETER VALIDATION ===
if (!is.character(language) || length(language) != 1) {
stop("'language' must be a single character string ('eng' or 'pt')", call. = FALSE)
}
language <- tolower(language)
if (!language %in% c("eng", "pt")) {
- stop("'language' must be either 'eng' (English) or 'pt' (Portuguese)", call. = FALSE)
+ stop("'language' must be either 'eng' or 'pt'", call. = FALSE)
}
- # Validate 'labels' parameter
if (!is.logical(labels) || length(labels) != 1) {
stop("'labels' must be a single logical value (TRUE or FALSE)", call. = FALSE)
}
- # Note: 'start_date' and 'end_date' are validated in the internal function
- # .normalize_date() which handles NULLs and various date formats
+ # === FUNCTION BODY ===
+ value <- NULL
- # Declare global variables for dplyr operations
- value <- gdp_nominal <- gdp_growth <- data_referencia <- crescimento_pib <- NULL
-
-
- # Use internal function to download data
+ # Download nominal GDP series (SGS 2010)
data <- .get_sgs_series(
- series_id = 2010, # GDP nominal code
+ series_id = 2010,
start_date = start_date,
end_date = end_date
)
- # Process the data
+ # Compute quarterly growth rate
data <- data |>
dplyr::arrange(date) |>
dplyr::mutate(
- gdp_nominal = as.numeric(value),
- gdp_growth = (gdp_nominal / dplyr::lag(gdp_nominal) - 1) * 100
+ value = (as.numeric(value) / dplyr::lag(as.numeric(value)) - 1) * 100
) |>
- dplyr::select(
- date,
- gdp_growth,
- gdp_nominal
- )
-
- # Note: date filtering is already applied in .get_sgs_series
- # No need for additional filtering here
-
- # Translation to Portuguese if needed
- if (language == "pt") {
- data <- data |>
- dplyr::rename(
- data_referencia = date,
- crescimento_pib = gdp_growth,
- pib_nominal = gdp_nominal
- )
- }
+ dplyr::select(date, value)
+ # Add labels if requested
if (isTRUE(labels) && requireNamespace("labelled", quietly = TRUE)) {
- if (tolower(language) == "pt") {
+
+ if (language == "pt") {
data <- labelled::set_variable_labels(
data,
- data_referencia = "Trimestre de referencia",
- crescimento_pib = "Crescimento do PIB real (%)",
- pib_nominal = "PIB nominal (R$ milhoes)"
+ date = "Trimestre de referencia",
+ value = "Crescimento do PIB (%)"
)
} else {
data <- labelled::set_variable_labels(
data,
- date = "Reference quarter",
- gdp_growth = "GDP growth rate (%)",
- gdp_nominal = "Nominal GDP (R$ millions)"
+ date = "Reference quarter",
+ value = "GDP growth rate (%)"
)
}
}
- # Remove gdp_nominal column from final result (keep only growth rate)
- if (tolower(language) == "pt") {
- data <- dplyr::select(data, data_referencia, crescimento_pib)
- } else {
- data <- dplyr::select(data, date, gdp_growth)
- }
-
return(data)
}
diff --git a/R/get_inflation_rate.R b/R/get_inflation_rate.R
index 8099f94..9a3e0c1 100644
--- a/R/get_inflation_rate.R
+++ b/R/get_inflation_rate.R
@@ -27,10 +27,10 @@
#' - `ytd_inflation` (numeric): Year-to-date accumulated inflation (%)
#' - `twelve_month_inflation` (numeric): 12-month accumulated inflation (%)
#' - Portuguese (`language = "pt"`):
-#' - `data_referencia` (Date): Mês de referência
-#' - `inflacao_mensal` (numeric): Variação mensal do IPCA (%)
-#' - `inflacao_acumulada_ano` (numeric): Inflação acumulada no ano (%)
-#' - `inflacao_12_meses` (numeric): Inflação acumulada nos últimos 12 meses (%)
+#' - `data_referencia` (Date): Mes de referencia
+#' - `inflacao_mensal` (numeric): Variacao mensal do IPCA (%)
+#' - `inflacao_acumulada_ano` (numeric): Inflacao acumulada no ano (%)
+#' - `inflacao_12_meses` (numeric): Inflacao acumulada nos ultimos 12 meses (%)
#'
#' @note
#' **Default Period**: When `start_date = NULL`, defaults to `"2020-01-01"`, providing
@@ -95,96 +95,62 @@ get_inflation_rate <- function(start_date = "2012-01-01",
# === FUNCTION BODY ===
# Declare global variables for dplyr operations
- value <- monthly_inflation <- year <- ytd_inflation <- twelve_month_inflation <- NULL
+ value <- monthly_inflation <- ytd_inflation <- twelve_month_inflation <- year <- NULL
- # Calculate start date for download (12 months earlier for 12-month inflation calculation)
- # First normalize the user's start_date
+ # === DATE NORMALIZATION ===
start_date_norm <- .normalize_date(start_date, is_start = TRUE)
+ end_date_norm <- .normalize_date(end_date, is_start = FALSE)
- # Download starting 12 months earlier than requested
- download_start_date <- start_date_norm - months(12)
- download_start_date_str <- format(download_start_date, "%Y-%m-%d")
+ download_start <- start_date_norm - lubridate::period(months = 12)
- # Use internal function to download data (SGS series 433 = IPCA monthly)
- # We need to pass the earlier start date for calculations
- data_full <- .get_sgs_series(
- series_id = 433, # Código do IPCA mensal
- start_date = download_start_date_str,
- end_date = end_date
+ # === DOWNLOAD DATA (IPCA mensal SGS 433) ===
+ data <- .get_sgs_series(
+ series_id = 433,
+ start_date = format(download_start, "%Y-%m-%d"),
+ end_date = end_date
)
- # Process the data - keep your original variable names
- data <- data_full |>
+ # === PROCESS DATA ===
+ data <- data |>
dplyr::arrange(date) |>
dplyr::mutate(
- monthly_inflation = as.numeric(value),
- year = lubridate::year(date)
+ value = as.numeric(value),
+ year = lubridate::year(date)
) |>
- dplyr::select(date, monthly_inflation, year)
-
- # Filter for end_date (if provided) - already handled in .get_sgs_series but double-check
- if (!is.null(end_date)) {
- end_date_norm <- .normalize_date(end_date, is_start = FALSE)
- data <- data |>
- dplyr::filter(date <= end_date_norm)
- }
-
- # Year-to-date accumulated inflation (your original calculation)
- data <- data |>
dplyr::group_by(year) |>
dplyr::mutate(
- ytd_inflation = (cumprod(1 + monthly_inflation / 100) - 1) * 100
+ ytd_inflation = (cumprod(1 + value / 100) - 1) * 100
) |>
- dplyr::ungroup()
-
- # 12-month accumulated inflation (your original calculation)
- data <- data |>
- dplyr::arrange(date) |>
+ dplyr::ungroup() |>
dplyr::mutate(
twelve_month_inflation = sapply(
- seq_along(monthly_inflation),
+ seq_along(value),
function(i) {
if (i < 12) return(NA_real_)
- (prod(1 + monthly_inflation[(i-11):i] / 100) - 1) * 100
+ (prod(1 + value[(i - 11):i] / 100) - 1) * 100
}
)
- )
-
- # Filter to show only the requested period (remove the extra 12 months)
- data <- data |>
- dplyr::filter(date >= start_date_norm)
-
- # Remove year column from final output (not in your original output)
- data <- dplyr::select(data, -year)
-
- # Translate column names if language = "pt" (your original logic)
- if (language == "pt") {
- data <- data |>
- dplyr::rename(
- data_referencia = date,
- inflacao_mensal = monthly_inflation,
- inflacao_acumulada_ano = ytd_inflation,
- inflacao_12_meses = twelve_month_inflation
- )
- }
+ ) |>
+ dplyr::filter(date >= start_date_norm & date <= end_date_norm) |>
+ dplyr::select(date, value, ytd_inflation, twelve_month_inflation)
- # Add labels if requested (your original logic)
+ # === LABELS ===
if (isTRUE(labels) && requireNamespace("labelled", quietly = TRUE)) {
if (language == "pt") {
data <- labelled::set_variable_labels(
data,
- data_referencia = "Mes de referencia",
- inflacao_mensal = "Variacao mensal do IPCA (%)",
- inflacao_acumulada_ano = "Inflacao acumulada no ano (%)",
- inflacao_12_meses = "Inflacao acumulada nos ultimos 12 meses (%)"
+ date = "Mes de referencia",
+ value = "Inflacao mensal IPCA (%)",
+ ytd_inflation = "Inflacao acumulada no ano (%)",
+ twelve_month_inflation = "Inflacao acumulada em 12 meses (%)"
)
} else {
data <- labelled::set_variable_labels(
data,
- date = "Reference month",
- monthly_inflation = "Monthly IPCA variation (%)",
- ytd_inflation = "Year-to-date accumulated inflation (%)",
- twelve_month_inflation = "12-month accumulated inflation (%)"
+ date = "Reference month",
+ value = "Monthly IPCA inflation (%)",
+ ytd_inflation = "Year-to-date inflation (%)",
+ twelve_month_inflation = "12-month inflation (%)"
)
}
}
diff --git a/R/get_selic_rate.R b/R/get_selic_rate.R
index f69e5e0..7d0dcd4 100644
--- a/R/get_selic_rate.R
+++ b/R/get_selic_rate.R
@@ -88,31 +88,23 @@ get_selic_rate <- function(start_date = "2020-01-01",
dplyr::arrange(date) |>
dplyr::select(
date,
- selic_rate = value # Rename for clarity
+ value
)
- # Translation to Portuguese if needed
- if (language == "pt") {
- data <- data |>
- dplyr::rename(
- data_referencia = date,
- taxa_selic = selic_rate
- )
- }
-
- # Add labels if requested and package is available
+ # === VARIABLE LABELS ===
if (isTRUE(labels) && requireNamespace("labelled", quietly = TRUE)) {
+
if (language == "pt") {
data <- labelled::set_variable_labels(
data,
- data_referencia = "Data de referencia",
- taxa_selic = "Taxa SELIC anual (% ao ano) - Sistema Especial de Liquidacao e Custodia"
+ date = "Data de referencia",
+ value = "Taxa SELIC anual (% ao ano)"
)
} else {
data <- labelled::set_variable_labels(
data,
date = "Reference date",
- selic_rate = "Annual SELIC rate (% per year) - Special System for Settlement and Custody"
+ value = "Annual SELIC rate (% per year)"
)
}
}
diff --git a/R/get_unemployment.R b/R/get_unemployment.R
index ec91766..3c92bb8 100644
--- a/R/get_unemployment.R
+++ b/R/get_unemployment.R
@@ -83,19 +83,12 @@ get_unemployment <- function(start_date = "2020-01-01",
stop("'labels' must be a single logical value (TRUE or FALSE)", call. = FALSE)
}
- # Check for required packages
- if (!requireNamespace("sidrar", quietly = TRUE)) {
- stop("The 'sidrar' package is required. Install with install.packages('sidrar')", call. = FALSE)
- }
-
- if (!requireNamespace("janitor", quietly = TRUE)) {
- stop("The 'janitor' package is required. Install with install.packages('janitor')", call. = FALSE)
- }
-
- if (!requireNamespace("stringr", quietly = TRUE)) {
- stop("The 'stringr' package is required. Install with install.packages('stringr')", call. = FALSE)
+ # Set default start_date if NULL (last 30 days by default for CDI)
+ if (is.null(start_date)) {
+ start_date <- Sys.Date() - 30 # Last 30 days
}
+ # === FUNCTION BODY ===
# Declare global variables for dplyr operations
value <- trimestre <- month <- year <- data <- NULL
@@ -116,7 +109,7 @@ get_unemployment <- function(start_date = "2020-01-01",
df <- dados |>
janitor::clean_names() |>
dplyr::select("trimestre_movel", "valor") |>
- dplyr::rename(trimestre = "trimestre_movel", rate = "valor") |>
+ dplyr::rename(trimestre = "trimestre_movel", value = "valor") |>
dplyr::mutate(
month = stringr::str_extract(trimestre, "(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)(?=\\s)"),
year = as.numeric(stringr::str_extract(trimestre, "\\d{4}$")),
@@ -124,21 +117,15 @@ get_unemployment <- function(start_date = "2020-01-01",
) |>
dplyr::filter(year >= start_year & year <= end_year)
- # Language-specific column names (MANTENDO OS NOMES ORIGINAIS)
if (language == "eng") {
- colnames(df) <- c("quarter", "rate", "month", "year", "date")
+ colnames(df) <- c("quarter", "value", "month", "year", "date")
} else {
- colnames(df) <- c("trimestre", "taxa", "mes", "ano", "data")
+ colnames(df) <- c("trimestre", "value", "mes", "ano", "date")
}
# Additional filtering by exact date range (more precise than just year)
- if (language == "eng") {
- df <- df |>
- dplyr::filter(date >= start_date_norm & date <= end_date_norm)
- } else {
- df <- df |>
- dplyr::filter(data >= start_date_norm & data <= end_date_norm)
- }
+ df <- df |>
+ dplyr::filter(date >= start_date_norm & date <= end_date_norm)
# Add labels if requested
if (isTRUE(labels) && requireNamespace("labelled", quietly = TRUE)) {
@@ -146,16 +133,16 @@ get_unemployment <- function(start_date = "2020-01-01",
df <- labelled::set_variable_labels(
df,
trimestre = "Trimestre movel de referencia",
- taxa = "Taxa de desemprego (%)",
+ value = "Taxa de desemprego (%)",
mes = "Mes de termino do trimestre",
ano = "Ano",
- data = "Data de referencia (primeiro dia do mes de termino)"
+ date = "Data de referencia (primeiro dia do mes de termino)"
)
} else {
df <- labelled::set_variable_labels(
df,
quarter = "Moving quarter reference",
- rate = "Unemployment rate (%)",
+ value = "Unemployment rate (%)",
month = "Quarter ending month",
year = "Year",
date = "Reference date (first day of quarter ending month)"
diff --git a/R/plot_cdi_rate.R b/R/plot_cdi_rate.R
new file mode 100644
index 0000000..e7c3d79
--- /dev/null
+++ b/R/plot_cdi_rate.R
@@ -0,0 +1,90 @@
+#' Plot Brazilian CDI rate
+#'
+#' Generates a time series plot of the CDI (Certificado de Depósito Interbancário) rate.
+#' The CDI is the benchmark interest rate for interbank deposits in Brazil and serves
+#' as a reference for many fixed income investments.
+#'
+#' @param data Tibble returned by `get_cdi_rate()`, with columns `date` and `value`.
+#' @param language Language for titles and labels: "pt" (Portuguese) or "eng" (English).
+#'
+#' @return A `ggplot2` object showing the CDI rate over time.
+#' @export
+#'
+#' @examples
+#' \dontrun{
+#' # Example 1: English version
+#' cdi_data <- get_cdi_rate(2020, 2024)
+#' cdi_plot <- plot_cdi_rate(cdi_data)
+#' print(cdi_plot)
+#'
+#' # Example 2: Portuguese version
+#' dados_cdi <- get_cdi_rate(2020, 2024, language = "pt")
+#' grafico_cdi <- plot_cdi_rate(dados_cdi, language = "pt")
+#' print(grafico_cdi)
+#' }
+
+plot_cdi_rate <- function(data,
+ language = "eng") {
+
+ # === PARAMETER VALIDATION ===
+
+ # Validate 'data' parameter
+ if (!is.data.frame(data)) {
+ stop("'data' must be a data frame or tibble", call. = FALSE)
+ }
+
+ required_cols <- c("date", "value")
+ missing_cols <- setdiff(required_cols, names(data))
+
+ if (length(missing_cols) > 0) {
+ stop(
+ paste0(
+ "'data' must contain columns: ",
+ paste(required_cols, collapse = ", ")
+ ),
+ call. = FALSE
+ )
+ }
+
+ if (!is.character(language) || length(language) != 1) {
+ stop("'language' must be a single character string ('eng' or 'pt')", call. = FALSE)
+ }
+
+ language <- tolower(language)
+ if (!language %in% c("eng", "pt")) {
+ stop("'language' must be either 'eng' (English) or 'pt' (Portuguese)", call. = FALSE)
+ }
+
+ # === FUNCTION BODY ===
+
+ # Declare global variables for dplyr operations
+ value <- taxa_cdi <- data_referencia <- rate <- NULL
+
+ # === TEXT DEFINITIONS ===
+
+ if (language == "eng") {
+ title <- "Brazil | CDI Rate"
+ y_label <- "Daily CDI rate (% per day)"
+ caption <- "Source: Central Bank of Brazil"
+ } else {
+ title <- "Brasil | Taxa CDI"
+ y_label <- "Taxa CDI diaria (% ao dia)"
+ caption <- "Fonte: Banco Central do Brasil"
+ }
+
+ # === PLOT ===
+
+ .plot_time_series(
+ data = data,
+ x_var = "date",
+ y_var = "value",
+ plot_type = "line",
+ title = title,
+ y_label = y_label,
+ caption = caption,
+ y_suffix = "%",
+ color = "#3498db",
+ show_points = TRUE,
+ date_breaks = "6 months"
+ )
+}
diff --git a/R/plot_exchange_rate.R b/R/plot_exchange_rate.R
new file mode 100644
index 0000000..faed804
--- /dev/null
+++ b/R/plot_exchange_rate.R
@@ -0,0 +1,91 @@
+#' Plot Brazilian exchange rate (USD/BRL)
+#'
+#' Generates a time series plot of the USD/BRL exchange rate using data from `get_exchange_rate()`.
+#' Shows the commercial exchange rate for US Dollar to Brazilian Real.
+#'
+#' @param data Tibble returned by `get_exchange_rate()`
+#' @param language Language for titles and labels: "pt" (Portuguese) or "eng" (English).
+#'
+#' @return A `ggplot2` object showing the exchange rate over time.
+#' @export
+#'
+#' @examples
+#' \dontrun{
+#' # Example 1: English version
+#' exchange_data <- get_exchange_rate("2023-01-01", "2023-12-31")
+#' exchange_plot <- plot_exchange_rate(exchange_data)
+#' print(exchange_plot)
+#'
+#' # Example 2: Portuguese version
+#' dados_cambio <- get_exchange_rate("2023-01-01", "2023-12-31", language = "pt")
+#' grafico_cambio <- plot_exchange_rate(dados_cambio, language = "pt")
+#' print(grafico_cambio)
+#' }
+
+plot_exchange_rate <- function(data,
+ language = "eng") {
+
+ # === PARAMETER VALIDATION ===
+
+ # Validate 'data' parameter
+ if (!is.data.frame(data)) {
+ stop("'data' must be a data frame or tibble", call. = FALSE)
+ }
+
+ required_cols <- c("date", "value")
+ missing_cols <- setdiff(required_cols, names(data))
+
+ if (length(missing_cols) > 0) {
+ stop(
+ paste0(
+ "'data' must contain columns: ",
+ paste(required_cols, collapse = ", ")
+ ),
+ call. = FALSE
+ )
+ }
+
+ if (!is.character(language) || length(language) != 1) {
+ stop("'language' must be a single character string ('eng' or 'pt')", call. = FALSE)
+ }
+
+ language <- tolower(language)
+ if (!language %in% c("eng", "pt")) {
+ stop("'language' must be either 'eng' (English) or 'pt' (Portuguese)", call. = FALSE)
+ }
+
+ # === FUNCTION BODY ===
+
+ # Declare global variables for dplyr operations
+ value <- cotacao <- rate <- NULL
+
+ # === TEXT DEFINITIONS ===
+
+ if (language == "eng") {
+ title <- "Brazil | Exchange Rate (USD/BRL)"
+ y_label <- "Exchange Rate (R$/US$)"
+ caption <- "Source: Central Bank of Brazil"
+ date_breaks <- "3 months"
+ } else {
+ title <- "Brasil | Taxa de Cambio (USD/BRL)"
+ y_label <- "Taxa de cambio (R$/US$)"
+ caption <- "Fonte: Banco Central do Brasil"
+ date_breaks <- "3 months"
+ }
+
+ # === PLOT ===
+
+ .plot_time_series(
+ data = data,
+ x_var = "date",
+ y_var = "value",
+ plot_type = "line",
+ title = title,
+ y_label = y_label,
+ caption = caption,
+ y_suffix = NULL,
+ color = "#2c3e50",
+ show_points = TRUE,
+ date_breaks = date_breaks
+ )
+}
diff --git a/R/plot_inflation_rate.R b/R/plot_inflation_rate.R
new file mode 100644
index 0000000..34427fb
--- /dev/null
+++ b/R/plot_inflation_rate.R
@@ -0,0 +1,86 @@
+#' Plot Brazilian Inflation Rate (IPCA)
+#'
+#' Generates a time series plot of Brazil's monthly inflation rate measured
+#' by the IPCA (Índice Nacional de Preços ao Consumidor Amplo).
+#' The IPCA is Brazil's official inflation index and is widely used for
+#' monetary policy decisions, contract indexation, and economic analysis.
+#'
+#' @param data Tibble returned by `get_inflation_rate()`, with columns `date` and `value`.
+#' The `value` column represents the monthly IPCA inflation rate (%).
+#' @param language Language for titles and labels: "pt" (Portuguese) or "eng" (English).
+#'
+#' @return A `ggplot2` object showing the monthly inflation rate over time.
+#' @export
+#'
+#' @examples
+#' \dontrun{
+#' # Example 1: English version
+#' inflation_data <- get_inflation_rate(2020, 2024)
+#' inflation_plot <- plot_inflation_rate(inflation_data)
+#' print(inflation_plot)
+#'
+#' # Example 2: Portuguese version
+#' dados_inflacao <- get_inflation_rate(2020, 2024, language = "pt")
+#' grafico_inflacao <- plot_inflation_rate(dados_inflacao, language = "pt")
+#' print(grafico_inflacao)
+#' }
+
+plot_inflation_rate <- function(data, language = "eng") {
+
+ # === PARAMETER VALIDATION ===
+
+ # Validate 'data' parameter
+ if (!is.data.frame(data)) {
+ stop("'data' must be a data frame or tibble", call. = FALSE)
+ }
+
+ required_cols <- c("date", "value")
+ missing_cols <- setdiff(required_cols, names(data))
+
+ if (length(missing_cols) > 0) {
+ stop(
+ paste0(
+ "'data' must contain columns: ",
+ paste(required_cols, collapse = ", ")
+ ),
+ call. = FALSE
+ )
+ }
+
+ if (!is.character(language) || length(language) != 1) {
+ stop("'language' must be a single character string ('eng' or 'pt')", call. = FALSE)
+ }
+
+ language <- tolower(language)
+ if (!language %in% c("eng", "pt")) {
+ stop("'language' must be either 'eng' (English) or 'pt' (Portuguese)", call. = FALSE)
+ }
+
+ # === FUNCTION BODY ===
+
+ # === TEXT DEFINITIONS ===
+ if (language == "eng") {
+ title <- "Brazil | Inflation Rate (IPCA)"
+ y_label <- "Monthly inflation (%)"
+ caption <- "Source: IBGE / Central Bank of Brazil (SGS 433)"
+ } else {
+ title <- "Brasil | Inflacao (IPCA)"
+ y_label <- "Inflacao mensal (%)"
+ caption <- "Fonte: IBGE / Banco Central do Brasil (SGS 433)"
+ }
+
+ # === PLOT ===
+ .plot_time_series(
+ data = data,
+ x_var = "date",
+ y_var = "value",
+ plot_type = "line",
+ title = title,
+ y_label = y_label,
+ caption = caption,
+ y_suffix = "%",
+ color = "#c0392b",
+ show_points = TRUE,
+ date_breaks = "6 months"
+ )
+}
diff --git a/R/plot_selic_rate.R b/R/plot_selic_rate.R
index 51e690f..710d251 100644
--- a/R/plot_selic_rate.R
+++ b/R/plot_selic_rate.R
@@ -27,69 +27,64 @@
plot_selic_rate <- function(data,
language = "eng") {
- if (!requireNamespace("ggplot2", quietly = TRUE)) {
- stop("The 'ggplot2' package is required. Install it with install.packages('ggplot2').")
+ # === PARAMETER VALIDATION ===
+
+ # Validate 'data' parameter
+ if (!is.data.frame(data)) {
+ stop("'data' must be a data frame or tibble", call. = FALSE)
}
- # Declare global variables for dplyr operations
- value <- selic_rate <- data_referencia <- taxa_selic <- NULL
+ required_cols <- c("date", "value")
+ missing_cols <- setdiff(required_cols, names(data))
- # === COMPATIBILITY LAYER: Map new column names to old expected names ===
- # This ensures backward compatibility while we update the vignette
- if (language == "pt") {
- # Portuguese: check for new column names and rename to old expected names
- if ("data_referencia" %in% names(data) && "taxa_selic" %in% names(data)) {
- data <- data |>
- dplyr::rename(data = data_referencia, taxa = taxa_selic)
- }
- # If columns are already "data" and "taxa", do nothing
- } else {
- # English: check for "selic_rate" and rename to "rate" if needed
- if ("selic_rate" %in% names(data)) {
- data <- data |>
- dplyr::rename(rate = selic_rate)
- }
+ if (length(missing_cols) > 0) {
+ stop(
+ paste0(
+ "'data' must contain columns: ",
+ paste(required_cols, collapse = ", ")
+ ),
+ call. = FALSE
+ )
}
- # Verifica se as colunas necessárias existem (APÓS o mapeamento)
- required_cols <- if (language == "eng") c("date", "rate") else c("data", "taxa")
+ if (!is.character(language) || length(language) != 1) {
+ stop("'language' must be a single character string ('eng' or 'pt')", call. = FALSE)
+ }
- missing_cols <- setdiff(required_cols, names(data))
- if (length(missing_cols) > 0) {
- stop("Dataframe is missing required columns: ", paste(missing_cols, collapse = ", "),
- "\nAvailable columns: ", paste(names(data), collapse = ", "))
+ language <- tolower(language)
+ if (!language %in% c("eng", "pt")) {
+ stop("'language' must be either 'eng' (English) or 'pt' (Portuguese)", call. = FALSE)
}
- # Define textos conforme o idioma
+ # === FUNCTION BODY ===
+
+ # Declare global variables for dplyr operations
+ value <- selic_rate <- data_referencia <- taxa_selic <- NULL
+
+ # === TEXT DEFINITIONS ===
+
if (language == "eng") {
- title <- "Brazil | SELIC Interest Rate (Effective Annual, 252-day basis)"
+ title <- "Brazil | SELIC Interest Rate (Effective Annual, 252-day basis)"
y_label <- "SELIC Rate (% p.a.)"
caption <- "Source: Central Bank of Brazil (SGS 1178)"
- x_var <- "date"
- y_var <- "rate" # Note: changed from "selic_rate" to "rate"
} else {
- title <- "Brasil | Taxa SELIC (Efetiva Anualizada, base 252)"
+ title <- "Brasil | Taxa SELIC (Efetiva Anualizada, base 252)"
y_label <- "Taxa SELIC (% a.a.)"
caption <- "Fonte: Banco Central do Brasil (SGS 1178)"
- x_var <- "data"
- y_var <- "taxa"
}
- # Gera o gráfico usando aes() com !!sym() para variáveis dinâmicas
- ggplot2::ggplot(data, ggplot2::aes(x = !!ggplot2::sym(x_var), y = !!ggplot2::sym(y_var))) +
- ggplot2::geom_step(color = "#1f78b4", linewidth = 1) +
- ggplot2::geom_point(color = "#e31a1c", size = 1) +
- ggplot2::scale_x_date(date_breaks = "6 months", date_labels = "%b/%Y") +
- ggplot2::scale_y_continuous(labels = scales::label_number(suffix = "%")) +
- ggplot2::labs(
- title = title,
- x = NULL,
- y = y_label,
- caption = caption
- ) +
- ggplot2::theme_minimal(base_size = 14) +
- ggplot2::theme(
- plot.title = ggplot2::element_text(face = "bold", hjust = 0.5),
- axis.text.x = ggplot2::element_text(angle = 45, hjust = 1)
- )
+ # === PLOT ===
+
+ .plot_time_series(
+ data = data,
+ x_var = "date",
+ y_var = "value",
+ plot_type = "step",
+ title = title,
+ y_label = y_label,
+ caption = caption,
+ y_suffix = "%",
+ color = "#1f78b4",
+ show_points = TRUE
+ )
}
diff --git a/R/plot_series_comparison.R b/R/plot_series_comparison.R
index c00ebae..a320306 100644
--- a/R/plot_series_comparison.R
+++ b/R/plot_series_comparison.R
@@ -53,6 +53,7 @@ plot_series_comparison <- function(data_list,
show_legend = TRUE,
legend_position = "bottom") {
+ # === PARAMETER VALIDATION ===
if (!requireNamespace("ggplot2", quietly = TRUE)) {
stop("The 'ggplot2' package is required. Install it with install.packages('ggplot2').")
}
@@ -65,6 +66,7 @@ plot_series_comparison <- function(data_list,
stop("The 'tidyr' package is required. Install it with install.packages('tidyr').")
}
+ # === FUNCTION BODY ===
# Declare global variables for dplyr operations
value <- series <- NULL
diff --git a/R/plot_time_series.R b/R/plot_time_series.R
index 23c9c99..ac669e0 100644
--- a/R/plot_time_series.R
+++ b/R/plot_time_series.R
@@ -44,62 +44,48 @@
y_suffix = NULL,
theme_base_size = 14,
rotate_x_angle = 45,
- show_points = TRUE,
- ...) {
+ show_points = TRUE) {
- if (!requireNamespace("ggplot2", quietly = TRUE)) {
- stop("The 'ggplot2' package is required. Install it with install.packages('ggplot2').")
- }
-
- if (!requireNamespace("scales", quietly = TRUE)) {
- stop("The 'scales' package is required. Install it with install.packages('scales').")
- }
-
- # Validate inputs
plot_type <- match.arg(plot_type)
- # Check if columns exist
- missing_cols <- setdiff(c(x_var, y_var), names(data))
- if (length(missing_cols) > 0) {
- stop("Dataframe is missing required columns: ",
- paste(missing_cols, collapse = ", "),
- "\nAvailable columns: ", paste(names(data), collapse = ", "))
- }
-
- # Set default colors if not provided
if (is.null(color)) {
color <- if (plot_type == "step") "#1f78b4" else "#2c3e50"
}
point_color <- if (plot_type == "step") "#e31a1c" else "#e74c3c"
- # Create base plot
- p <- ggplot2::ggplot(data, ggplot2::aes(x = !!ggplot2::sym(x_var),
- y = !!ggplot2::sym(y_var)))
-
- # Add the main geom based on plot_type
- switch(plot_type,
- "line" = {
- p <- p + ggplot2::geom_line(color = color, linewidth = line_size, ...)
- if (show_points) {
- p <- p + ggplot2::geom_point(color = point_color, size = point_size)
- }
- },
- "step" = {
- p <- p + ggplot2::geom_step(color = color, linewidth = line_size, ...)
- if (show_points) {
- p <- p + ggplot2::geom_point(color = point_color, size = point_size)
- }
- },
- "bar" = {
- p <- p + ggplot2::geom_bar(stat = "identity", fill = color, ...)
- },
- "point" = {
- p <- p + ggplot2::geom_point(color = color, size = point_size, ...)
- }
+ p <- ggplot2::ggplot(
+ data,
+ ggplot2::aes(
+ x = !!ggplot2::sym(x_var),
+ y = !!ggplot2::sym(y_var)
+ )
)
- # Apply theme and scales
+ if (plot_type %in% c("line", "step")) {
+ geom_fun <- if (plot_type == "line") ggplot2::geom_line else ggplot2::geom_step
+
+ p <- p + geom_fun(color = color, linewidth = line_size)
+
+ if (isTRUE(show_points)) {
+ p <- p + ggplot2::geom_point(
+ color = point_color,
+ size = point_size
+ )
+ }
+ }
+
+ if (plot_type == "bar") {
+ p <- p + ggplot2::geom_col(fill = color)
+ }
+
+ if (plot_type == "point") {
+ p <- p + ggplot2::geom_point(
+ color = color,
+ size = point_size
+ )
+ }
+
p <- p +
ggplot2::theme_minimal(base_size = theme_base_size) +
ggplot2::theme(
@@ -112,7 +98,6 @@
)
)
- # Format x-axis if it's a date
if (inherits(data[[x_var]], c("Date", "POSIXct", "POSIXt"))) {
p <- p + ggplot2::scale_x_date(
date_breaks = date_breaks,
@@ -120,14 +105,12 @@
)
}
- # Format y-axis
if (!is.null(y_suffix)) {
p <- p + ggplot2::scale_y_continuous(
labels = scales::label_number(suffix = y_suffix)
)
}
- # Add labels
p <- p + ggplot2::labs(
title = title,
subtitle = subtitle,
diff --git a/R/plot_unemployment.R b/R/plot_unemployment.R
index 2de19b6..c7e128e 100644
--- a/R/plot_unemployment.R
+++ b/R/plot_unemployment.R
@@ -21,52 +21,65 @@
#' print(grafico_desemprego)
#' }
-
plot_unemployment <- function(data,
language = "eng") {
- if (!requireNamespace("ggplot2", quietly = TRUE)) {
- stop("The 'ggplot2' package is required. Install it with install.packages('ggplot2').")
+ # === PARAMETER VALIDATION ===
+
+ # Validate 'data' parameter
+ if (!is.data.frame(data)) {
+ stop("'data' must be a data frame or tibble", call. = FALSE)
}
- # Verifica se as colunas necessárias existem
- required_cols <- if (language == "eng") c("date", "rate") else c("data", "taxa")
+ required_cols <- c("date", "value")
missing_cols <- setdiff(required_cols, names(data))
+
if (length(missing_cols) > 0) {
- stop("Dataframe is missing required columns: ", paste(missing_cols, collapse = ", "))
+ stop(
+ paste0(
+ "'data' must contain columns: ",
+ paste(required_cols, collapse = ", ")
+ ),
+ call. = FALSE
+ )
+ }
+
+ if (!is.character(language) || length(language) != 1) {
+ stop("'language' must be a single character string ('eng' or 'pt')", call. = FALSE)
}
- # Define textos conforme o idioma
+ language <- tolower(language)
+ if (!language %in% c("eng", "pt")) {
+ stop("'language' must be either 'eng' (English) or 'pt' (Portuguese)", call. = FALSE)
+ }
+
+ # === FUNCTION BODY ===
+
+ # === TEXT DEFINITIONS ===
+
if (language == "eng") {
- title <- "Brazil | Unemployment Rate (Continuous PNAD)"
+ title <- "Brazil | Unemployment Rate (Continuous PNAD)"
y_label <- "Unemployment Rate (%)"
caption <- "Source: IBGE - SIDRA (Table 6381)"
- x_var <- "date"
- y_var <- "rate"
} else {
- title <- "Brasil | Taxa de Desemprego (PNAD Continua)"
+ title <- "Brasil | Taxa de Desemprego (PNAD Continua)"
y_label <- "Taxa de desemprego (%)"
caption <- "Fonte: IBGE - SIDRA (Tabela 6381)"
- x_var <- "data"
- y_var <- "taxa"
}
- # Gera o gráfico usando aes() com !!sym() para variáveis dinâmicas
+ # === PLOT ===
- ggplot2::ggplot(data, ggplot2::aes(x = !!ggplot2::sym(x_var), y = !!ggplot2::sym(y_var))) +
- ggplot2::geom_line(color = "#2c3e50", linewidth = 1) +
- ggplot2::geom_point(color = "#e74c3c", size = 2) +
- ggplot2::theme_minimal(base_size = 14) +
- ggplot2::scale_x_date(date_breaks = "6 months", date_labels = "%b/%Y") +
- ggplot2::scale_y_continuous(labels = scales::label_number(suffix = "%")) +
- ggplot2::labs(
- title = title,
- x = NULL,
- y = y_label,
- caption = caption
- ) +
- ggplot2::theme(
- plot.title = ggplot2::element_text(face = "bold", hjust = 0.5),
- axis.text.x = ggplot2::element_text(angle = 45, hjust = 1)
- )
+ .plot_time_series(
+ data = data,
+ x_var = "date",
+ y_var = "value",
+ plot_type = "line",
+ title = title,
+ y_label = y_label,
+ caption = caption,
+ y_suffix = "%",
+ color = "#2c3e50",
+ show_points = TRUE,
+ date_breaks = "1 year"
+ )
}
diff --git a/man/get_cdi_rate.Rd b/man/get_cdi_rate.Rd
index c365fe7..6fcfbb8 100644
--- a/man/get_cdi_rate.Rd
+++ b/man/get_cdi_rate.Rd
@@ -37,10 +37,11 @@ get_cdi_rate(
package. Labels provide descriptive text for each column when available.}
}
\value{
-A data.frame with CDI rate. Columns depend on the \code{language} parameter:
-\itemize{
-\item English (\code{language = "eng"}): \code{date} (Date), \code{cdi_rate} (numeric, \% per year)
-\item Portuguese (\code{language = "pt"}): \code{data_referencia} (Date), \code{taxa_cdi} (numeric, \% ao ano)
+A data.frame with columns:
+\describe{
+\item{date}{Reference date}
+\item{value}{Daily CDI rate (\% per day)}
+\item{value_annualized}{Annualized CDI rate (\% per year, 252 business days)}
}
}
\description{
diff --git a/man/get_inflation_rate.Rd b/man/get_inflation_rate.Rd
index c513ad9..964015e 100644
--- a/man/get_inflation_rate.Rd
+++ b/man/get_inflation_rate.Rd
@@ -49,10 +49,10 @@ A data.frame with inflation metrics. Columns depend on the \code{language} param
}
\item Portuguese (\code{language = "pt"}):
\itemize{
-\item \code{data_referencia} (Date): Mês de referência
-\item \code{inflacao_mensal} (numeric): Variação mensal do IPCA (\%)
-\item \code{inflacao_acumulada_ano} (numeric): Inflação acumulada no ano (\%)
-\item \code{inflacao_12_meses} (numeric): Inflação acumulada nos últimos 12 meses (\%)
+\item \code{data_referencia} (Date): Mes de referencia
+\item \code{inflacao_mensal} (numeric): Variacao mensal do IPCA (\%)
+\item \code{inflacao_acumulada_ano} (numeric): Inflacao acumulada no ano (\%)
+\item \code{inflacao_12_meses} (numeric): Inflacao acumulada nos ultimos 12 meses (\%)
}
}
}
diff --git a/man/plot_cdi_rate.Rd b/man/plot_cdi_rate.Rd
new file mode 100644
index 0000000..a3f08ac
--- /dev/null
+++ b/man/plot_cdi_rate.Rd
@@ -0,0 +1,34 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/plot_cdi_rate.R
+\name{plot_cdi_rate}
+\alias{plot_cdi_rate}
+\title{Plot Brazilian CDI rate}
+\usage{
+plot_cdi_rate(data, language = "eng")
+}
+\arguments{
+\item{data}{Tibble returned by \code{get_cdi_rate()}, with columns \code{date} and \code{value}.}
+
+\item{language}{Language for titles and labels: "pt" (Portuguese) or "eng" (English).}
+}
+\value{
+A \code{ggplot2} object showing the CDI rate over time.
+}
+\description{
+Generates a time series plot of the CDI (Certificado de Depósito Interbancário) rate.
+The CDI is the benchmark interest rate for interbank deposits in Brazil and serves
+as a reference for many fixed income investments.
+}
+\examples{
+\dontrun{
+# Example 1: English version
+cdi_data <- get_cdi_rate(2020, 2024)
+cdi_plot <- plot_cdi_rate(cdi_data)
+print(cdi_plot)
+
+# Example 2: Portuguese version
+dados_cdi <- get_cdi_rate(2020, 2024, language = "pt")
+grafico_cdi <- plot_cdi_rate(dados_cdi, language = "pt")
+print(grafico_cdi)
+}
+}
diff --git a/man/plot_exchange_rate.Rd b/man/plot_exchange_rate.Rd
new file mode 100644
index 0000000..1b868a4
--- /dev/null
+++ b/man/plot_exchange_rate.Rd
@@ -0,0 +1,33 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/plot_exchange_rate.R
+\name{plot_exchange_rate}
+\alias{plot_exchange_rate}
+\title{Plot Brazilian exchange rate (USD/BRL)}
+\usage{
+plot_exchange_rate(data, language = "eng")
+}
+\arguments{
+\item{data}{Tibble returned by \code{get_exchange_rate()}}
+
+\item{language}{Language for titles and labels: "pt" (Portuguese) or "eng" (English).}
+}
+\value{
+A \code{ggplot2} object showing the exchange rate over time.
+}
+\description{
+Generates a time series plot of the USD/BRL exchange rate using data from \code{get_exchange_rate()}.
+Shows the commercial exchange rate for US Dollar to Brazilian Real.
+}
+\examples{
+\dontrun{
+# Example 1: English version
+exchange_data <- get_exchange_rate("2023-01-01", "2023-12-31")
+exchange_plot <- plot_exchange_rate(exchange_data)
+print(exchange_plot)
+
+# Example 2: Portuguese version
+dados_cambio <- get_exchange_rate("2023-01-01", "2023-12-31", language = "pt")
+grafico_cambio <- plot_exchange_rate(dados_cambio, language = "pt")
+print(grafico_cambio)
+}
+}
diff --git a/man/plot_inflation_rate.Rd b/man/plot_inflation_rate.Rd
new file mode 100644
index 0000000..1e3daeb
--- /dev/null
+++ b/man/plot_inflation_rate.Rd
@@ -0,0 +1,36 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/plot_inflation_rate.R
+\name{plot_inflation_rate}
+\alias{plot_inflation_rate}
+\title{Plot Brazilian Inflation Rate (IPCA)}
+\usage{
+plot_inflation_rate(data, language = "eng")
+}
+\arguments{
+\item{data}{Tibble returned by \code{get_inflation_rate()}, with columns \code{date} and \code{value}.
+The \code{value} column represents the monthly IPCA inflation rate (\%).}
+
+\item{language}{Language for titles and labels: "pt" (Portuguese) or "eng" (English).}
+}
+\value{
+A \code{ggplot2} object showing the monthly inflation rate over time.
+}
+\description{
+Generates a time series plot of Brazil's monthly inflation rate measured
+by the IPCA (Índice Nacional de Preços ao Consumidor Amplo).
+The IPCA is Brazil's official inflation index and is widely used for
+monetary policy decisions, contract indexation, and economic analysis.
+}
+\examples{
+\dontrun{
+# Example 1: English version
+inflation_data <- get_inflation_rate(2020, 2024)
+inflation_plot <- plot_inflation_rate(inflation_data)
+print(inflation_plot)
+
+# Example 2: Portuguese version
+dados_inflacao <- get_inflation_rate(2020, 2024, language = "pt")
+grafico_inflacao <- plot_inflation_rate(dados_inflacao, language = "pt")
+print(grafico_inflacao)
+}
+}
diff --git a/vignettes/about.Rmd b/vignettes/about.Rmd
deleted file mode 100644
index f4ca530..0000000
--- a/vignettes/about.Rmd
+++ /dev/null
@@ -1,26 +0,0 @@
----
-title: "About the Author"
-output: rmarkdown::html_vignette
-vignette: >
- %\VignetteIndexEntry{About the Author}
- %\VignetteEngine{knitr::rmarkdown}
- %\VignetteEncoding{UTF-8}
----
-
-**João Paulo dos Santos Pereira Barbosa** is an undergraduate student in **Economics at PUC-Rio (Pontifical Catholic University of Rio de Janeiro)**, currently in his 5th semester.
-He focuses on **financial analysis and data science**, working at the intersection between **economics and technology** to transform data into strategic insights.
-
-💡 João is the **developer of the `{brfinance}` package**, available on the
-[CRAN (R Project)](https://cran.r-project.org/package=brfinance).
-This personal initiative was designed to make **Brazilian financial and macroeconomic data more accessible and easier to analyze directly within R**, combining automation with analytical precision.
-
-He also participates in an **academic exchange program in Ecuador**, an experience that has broadened his understanding of regional integration and Latin American economic policies.
-
-João has experience in **valuation**, **financial statement analysis**, and **programming in R and Python**.
-He is passionate about developing open-source tools that make **economic research and data-driven decision-making more accessible**.
-
-His professional goal is to pursue a career as a **Quantitative Analyst** or **Data Scientist**, combining the rigor of economic theory with the ability to translate data into tangible value for investment and strategy.
-
-**Contact:** [joao.31582129@gmail.com](mailto:joao.31582129@gmail.com)
-**LinkedIn:** [João Paulo Barbosa](https://www.linkedin.com/in/jo%C3%A3o-paulo-barbosa-6896241bb/)
-**GitHub:** [efram2](https://github.com/efram2)