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/siconfiBD") | |
| #Atenção: Deve-se instalar ainda os pacotes tidyverse e viridis | |
| #Esses scripts estão associados a esse fio do twitter: | |
| #É necessário ter uma conta no google cloud | |
| siconfiBD::setup_siconfi( <aqui_seu_projeto_google_cloud>) | |
| #Se você quiser saber as despesas com todas as funções e sub-funções de governo para todos os municípios do Brasil para o |
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(ckanr) | |
| library(purrr) | |
| ckanr::package_search() | |
| package<- ckanr::package_show(id= "22d13d17-bf69-4a1a-add2-25cc1e25f2d7", | |
| url= "https://www.tesourotransparente.gov.br/ckan") #busca todos os dados do dataset que se refere aos dados de COFOG | |
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(geobr) | |
| #O arquivo csv abaixo foi gerado a partir de uma consluta SQL do Big Query provido pela Base dos dados. | |
| #Saiba mais sobre base dos dados em https://basedosdados.org/ | |
| #A consulta SQL exceutada no big query é essa: | |
| #SELECT * | |
| #FROM `basedosdados.br_ibge_populacao.municipio` | |
| #where ano = 2020 |
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 from CRAN | |
| install.packages("pixarfilms") | |
| # Install directly from GitHub | |
| remotes::install_github("erictleung/pixarfilms") | |
| library(pixarfilms) | |
| library(tidyverse) | |
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
| #Script para geração dos mapas usados no artigo da revista medium indicada no link abaixo | |
| #https://medium.com/@fernandobarbalho/mapas-contando-hist%C3%B3ria-o-pib-dos-munic%C3%ADpios-brasileiros-aebb82f06086?source=friends_link&sk=cfb19f1276b5b8aea5a65672fb897dc8 | |
| library(readxl) | |
| library(tidyr) | |
| library(tidyverse) | |
| library(viridis) | |
| library(purrr) | |
| #consumir os dados do ibge |
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", |
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
| # 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
| #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
| 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){ |