Last active
January 30, 2020 13:33
-
-
Save sergiospagnuolo/7c1baa9ac3dc9eb37c7dd5087f3eee2a to your computer and use it in GitHub Desktop.
análises de bolsas CNPQ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dados podem ser obtidos em: http://memoria.cnpq.br/painel-de-investimentos | |
library(tidyverse) | |
library(deflateBR) | |
library(lubridate) | |
d <- read.csv("cnpq_investimentos.csv", header = T) | |
d$Ano.Referência <- gsub("206", "2006", d$Ano.Referência) | |
d$ano <- as.Date(d$Ano.Referência, origin="2002-09-11", format = "%Y") | |
d$valor <- as.numeric(sub(",", ".", d$Valor.Pago, fixed = TRUE)) | |
d$ajustado <- deflate(d$valor, d$ano, "07/2019", "ipca") | |
d$ano <- format(d$ano, format = "%Y") | |
View(head(d)) | |
anual <- d %>% | |
select(ano, ajustado) %>% | |
group_by(ano) %>% | |
summarise(ajustado = sum(ajustado)) %>% | |
add_row(ano = 2019, ajustado = 1200000000) %>% | |
mutate(var_ano = round(((ajustado/lag(ajustado) - 1) * 100),1)) %>% | |
filter(ano > 2005) | |
View(anual) | |
variacao_anual <- ggplot(anual, aes(ano, var_ano)) + | |
geom_bar(aes(fill = var_ano < 0), stat = "identity") + | |
scale_fill_manual(guide = FALSE, breaks = c(TRUE, FALSE), values=c("#386cb0", "#f0027f")) + | |
scale_y_continuous(labels=function(x) format(x, big.mark = ",", scientific = FALSE)) + | |
labs(title = "Investimentos em bolsas do CNPQ", | |
subtitle = "Valores ajustados pelo IPCA", | |
y = "variação percentual (%)", | |
caption = "Fonte: CNPQ/DeflateBR") + | |
theme_bw(base_size = 14, | |
base_family = "Inconsolata") | |
variacao_anual | |
investimentos <- ggplot(anual, aes(x = ano, y = ajustado, group = 1)) + | |
geom_point(color = "#386cb0") + | |
geom_line(color = "#386cb0") + | |
scale_y_continuous(labels=function(x) format(x, big.mark = ",", scientific = FALSE)) + | |
labs(title = "Investimentos em bolsas do CNPQ", | |
subtitle = "Valores ajustados pelo IPCA", | |
y = "resultado em Reais", | |
caption = "Fonte: CNPQ/DeflateBR") + | |
theme_bw(base_size = 14, | |
base_family = "Inconsolata") | |
investimentos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment