Last active
November 25, 2019 17:26
-
-
Save sergiospagnuolo/83d149286d9ccd8dc56a5a70bb8b6985 to your computer and use it in GitHub Desktop.
Script para análise de concessões de bolsas Capes desde 2000 até último dado disponível
This file contains hidden or 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
library(readxl) | |
library(tidyverse) | |
# Distribuição de Bolsas de Pós-graduação no Brasil | |
# ref https://geocapes.capes.gov.br/geocapes/ | |
url <- "https://geocapes.capes.gov.br/geocapes/rest/fotoDados/indicador/1/false/download?[]" | |
download.file(url, basename(url)) | |
d <- read_excel("download?[]") | |
# dá pra carregar diretamente pelo arquivo | |
#d <- read_excel("dados.xlsx") | |
b <- d %>% | |
select(1:12, MESTRADO, `DOUTORADO PLENO`) %>% | |
gather(tipo, bolsas, -1:-12, factor_key = TRUE) | |
a <- b %>% group_by(Ano, tipo) %>% summarise(sum(bolsas)) | |
colnames(a)[3] = "valor" | |
#grafico1 <- b %>% ggplot(aes(Ano, bolsas, colour = tipo)) + geom_point(alpha = 0.5) | |
# gráfico sobre distribuicao de bolsas no Brasil por ano | |
grafico2 <- a %>% | |
filter(Ano >= 2000) %>% | |
ggplot(aes(Ano, valor , fill=tipo)) + | |
geom_bar(stat = "identity", position = "dodge", show.legend = TRUE, alpha = 0.5) + | |
# usa metodologia de regressão local (http://www.leg.ufpr.br/lib/exe/fetch.php/projetos:saudavel:loess.pdf) | |
geom_smooth(method='loess', se = FALSE, colour = "#555555") + | |
scale_fill_manual(values=c("#386cb0","#B80062")) + | |
scale_y_continuous(labels=function(x) format(x, big.mark = ",", scientific = FALSE)) + | |
labs(title="Números da CAPES", | |
subtitle = "Distribuição de Bolsas de Pós-graduação no Brasil desde ano 2000,\nusando regressão loess para linha de tendência", | |
x="", | |
y="bolsas concedidas", | |
fill = "", | |
caption = "Fonte: CAPES") | |
grafico2 | |
# calcula crescimento percentual | |
grafico3 <- a %>% | |
filter(Ano >= 1999) %>% | |
group_by(tipo) %>% | |
arrange(Ano, .by_group = TRUE) %>% | |
mutate(var_ano = ((valor/lag(valor) - 1) * 100)) %>% | |
ggplot(aes(Ano, var_ano , fill=tipo)) + | |
geom_bar(stat = "identity", position = "dodge", show.legend = TRUE, alpha = 0.5) + | |
scale_fill_manual(values=c("#386cb0","#B80062")) + | |
scale_y_continuous(labels=function(x) format(x, big.mark = ",", scientific = FALSE)) + | |
labs(title="Números da CAPES", | |
subtitle = "Variação percentual de concessões de bolsa ano a ano, de 2000 a 2018", | |
x="", | |
y="variação %", | |
fill = "", | |
caption = "Fonte: CAPES") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment