Skip to content

Instantly share code, notes, and snippets.

@Athospd
Last active January 13, 2023 22:31
Show Gist options
  • Save Athospd/d374b306dd7289102f82e9b1142660ad to your computer and use it in GitHub Desktop.
Save Athospd/d374b306dd7289102f82e9b1142660ad to your computer and use it in GitHub Desktop.
Gastos dos cartoes corporativos dos presidentes do BR entre 2003 e 2022
---
title: "Cartao Corporativo dos Presidentes do Brasil - 2003 a 2022"
author: "Athos Damiani"
---
```{r}
library(tidyverse)
library(lubridate)
```
```{r}
dados <- readr::read_csv2("https://www.gov.br/secretariageral/pt-br/acesso-a-informacao/informacoes-classificadas-e-desclassificadas/Planilha12003a2022.csv", locale = readr::locale(encoding = "latin1")) %>%
mutate(
DATA_PGTO = dmy(`DATA PGTO`),
ANO_MES_DATA = floor_date(DATA_PGTO, unit = "1 month"),
ANO = year(DATA_PGTO),
PRESIDENTE = case_when(
ANO <= 2010 ~ "Lula",
ANO <= 2016 ~ "Dilma",
ANO <= 2018 ~ "Temer",
ANO <= 2022 ~ "Bolsonaro"
)
) %>%
mutate(
VALOR = VALOR %>% str_remove("R\\$ ") %>% parse_number(locale = readr::locale(decimal_mark = ",")),
VALOR_CORRIGIDO = deflateBR::deflate(VALOR, DATA_PGTO, "01/2003", "ipca")
)
```
```{r}
dados %>%
group_by(PRESIDENTE, ANO) %>%
summarise(
VALOR = sum(VALOR_CORRIGIDO, na.rm = TRUE)/1e6
) %>%
ggplot(aes(x = ANO, y = VALOR, fill = PRESIDENTE)) +
geom_col() +
labs(x = "Ano", y = "Gasto (em milhões de Reais")
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment