---
title: "2. Inflation Analysis"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{inflation}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
# Definir mirror do CRAN primeiro
options(repos = c(CRAN = "https://cloud.r-project.org/"))

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

## get_inflation_rate()

Downloads monthly IPCA inflation data from Central Bank of Brazil.
 
### Parameters

- `start_date`: Start date "YYYY-MM-DD" (default: "2012-01-01")
- `end_date`: End date "YYYY-MM-DD" (default: NULL - most recent)
- `language`: Column names - `"eng"` (default) or `"pt"`
- `labels`: Whether to add variable labels (default: TRUE)

### Usage

```{r inflation-usage, eval=FALSE}
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"
)
```

### Output Structure

**English:**
```
# A tibble: 156 × 5
   date       monthly_inflation ytd_inflation twelve_month_inflation year
   <date>                 <dbl>         <dbl>                 <dbl> <dbl>
 1 2020-01-01             0.21          0.21                  4.18  2020
```

**Portuguese:**
```
# A tibble: 156 × 5
   data_referencia inflacao_mensal inflacao_acumulada_ano inflacao_12_meses   ano
   <date>                     <dbl>                 <dbl>             <dbl> <dbl>
 1 2020-01-01                 0.21                  0.21              4.18  2020
```

*Returned data:*

* Monthly IPCA variation
* Year-to-date accumulated
* 12-month accumulated
