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
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
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
#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
#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
#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
#Faça download de um conjunto de tabelas do bolsa família referente a qualquer período a partir de janeiro de 2003 | |
base_address<- "http://transparencia.gov.br/download-de-dados/bolsa-familia-pagamentos/" | |
#Alterar as variáveis abaixo de acordo com o que se deseja | |
ano_ini<- 2018 | |
ano_fim<- 2018 | |
mes_ini<-1 | |
ult_mes_disp<- 2 |
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(readr) | |
library(dplyr) | |
PENSIONISTAS_112019 <- read_delim("Data/PENSIONISTAS_112019.csv", | |
";", escape_double = FALSE, locale = locale(decimal_mark = ",", | |
grouping_mark = ".", encoding = "LATIN1"), | |
trim_ws = TRUE) | |
PENSIONISTAS_122019 <- read_delim("Data/PENSIONISTAS_122019.csv", | |
";", escape_double = FALSE, locale = locale(decimal_mark = ",", |
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") | |
library(rsiconfi) | |
library(dplyr) | |
library(tidyr) | |
###########Trabalhando as despesas | |
#Monta um vetor com todos os códigos de UFs do Brasil |
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(tabulizer) | |
library(dplyr) | |
setwd("~/GitHub/oleogate/data") | |
#Extrai tabelas do arquivo pdf. | |
#Esse arquivo foi baixado do seguinte link | |
# https://politica.estadao.com.br/blogs/estadao-verifica/wp-content/uploads/sites/690/2019/10/Ibama.pdf | |
#A tabela é extraída para um arquivo csv de forma a poder trabalhar melhor questões de encoding | |
tabulizer::extract_tables("ibama.pdf", output = "csv",outdir = getwd()) |