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
#O script abaixo consome dados consolidados de bolsa família para todos os municípios | |
#Como o script demora muito, considere fazer alterações para fazer filtros antes do segundo pull | |
ano<-2014 | |
pbf_mun<- owdbr::uflist() %>% | |
pull(num)%>% | |
map_dfr(munlist) %>% | |
pull(codigo_municipio_completo) %>% | |
map_dfr(getpbf_mun,AAAA= ano) |
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
#based on this method: https://github.com/k-sys/covid-19/blob/master/Realtime%20R0.ipynb | |
# In fact it is a translation from python to R of some parts of the code explained in the link above. | |
get_last_covid_rt<- function(df_days_case){ #this dataset must have a structre with a collumn no_cases (accumulated number of cases on a given sequence day) | |
#smooth the data | |
x <- 1:NROW(df_days_case) | |
y<-df_days_case$no_cases |
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
#para essa função usa-se o pacote microdatasus | |
# SALDANHA, Raphael de Freitas; BASTOS, Ronaldo Rocha; BARCELLOS, Christovam. Microdatasus: pacote para download e pré-processamento de microdados do Departamento de Informática do SUS (DATASUS). Cad. Saúde Pública, Rio de Janeiro , v. 35, n. 9, e00032419, 2019 . Available from http://ref.scielo.org/dhcq3y. | |
process_SIM_all_fu<- function(a_year_start, a_year_end){ | |
library(microdatasus) | |
library(dplyr) | |
library(purrr) | |
library(readr) | |
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(rtweet) | |
library(dplyr) | |
library(ggplot2) | |
df_favorite<- rtweet::get_favorites("@barbalhofernand", n=3000) | |
users_favorite<- | |
df_favorite %>% | |
group_by(screen_name, user_id) %>% |
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
devtools::install_github("tchiluanda/rsiconfi") | |
library(rsiconfi) | |
library(networkD3) | |
library(tidyverse) | |
#Get data in SICONFI for budget revenue (Ï-C) related to the federal government entity (1) in 2018 | |
df_rec <- rsiconfi::get_dca(2018,"I-C","1") | |
# find hierachical strtucture of budget revenue |
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
get_covid_data_jhu<- function(dt_ini, dt_fim, us_columns = TRUE, country = NULL ){ #data inicial para o download, data final para o download, indicação se trabalha com colunas dos EUA (TRUE por default) e lista de países (todos por default) | |
library(dplyr) | |
#cria um vetor de datas que vai ser iterado na formação do endereço de github que tem os dados | |
dates<- c(lubridate::ymd(dt_ini):lubridate::ymd(dt_fim)) | |
#O map_dfr vai montar dinamicamente um único dataframe com as para todas as datas do array | |
purrr::map_dfr(dates, function(a_date){ |
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
#Criar gráfico de sankey | |
df_desp <- rsiconfi::get_dca(2018,"I-D","1") | |
df_desp_trabalho<- | |
df_desp %>% | |
#filter(stringr::str_starts(cod_conta,"R")) %>% | |
filter(coluna == "Despesas Liquidadas") %>% | |
mutate(nivel_0 = cod_conta =="TotalDespesas" ) %>% |
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
# install.packages("devtools") | |
# devtools::install_github("tchiluanda/rsiconfi") | |
#Criar gráfico de sankey | |
df_desp <- get_dca(2018,"I-D","1") | |
df_desp_trabalho<- | |
df_desp %>% |
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
calcula_valor_constante <- function(df_dados_hist, data_constante ){ | |
#Argumentos | |
#df_dados_hist: dataframe em que as duas primeiras colunas são formadas por uma data (Y-m-d) e um valor | |
#data_constante: data para gerar valor constante. Formato da data: Y-m-d | |
#Por enquanto as datas estão limitadas à da série temporal baixada do IPCA Total do portal de dados abertos do BACEN | |
#Essa série começa em 1992-01-01 | |
library(dplyr) | |
library(lubridate) |
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(readr) | |
library(tidyverse) | |
library(lubridate) | |
library(rsiconfi) | |
arquivo_geral <- read_excel("HIST_PAINEL_COVIDBR_30jun2020.xlsx", | |
col_types = c("text", "text", "numeric", | |
"text", "numeric", "numeric", "numeric", | |
"date", "numeric", "text", "numeric", |