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
#View que gera o cálculo do total de despesas pagas para todas as funçoes de governo de todos os municípios | |
CREATE OR REPLACE VIEW `nice-diorama-306223.objetos_apoio.vw_total_municipios_despesas` AS | |
SELECT id_municipio, | |
sum(valor) total_despesa | |
FROM `basedosdados.br_me_siconfi.municipio_despesas_funcao` despesa | |
where ano = 2023 and | |
estagio_bd = "Despesas Pagas" and | |
(id_conta_bd is null or id_conta_bd = "3.00.000") #Despesa intraorçamentárias ou despesas exceto intraorçamentárias | |
group by id_municipio; |
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
# Os dados estão presentes no repositório big query da base dos dados | |
SELECT id_municipio, | |
count(*) as quantidade_nivel_superior, | |
( select count(*) | |
from `basedosdados.br_me_rais.microdados_vinculos` vinc_sub | |
where vinc_sub.id_municipio = vinc.id_municipio and | |
ano = 2023 and | |
vinculo_ativo_3112 ="1" and | |
natureza_juridica = "1244") as total_servidores_municipio, #1244= município |
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
#Lê o arquivo baixado do portal do MCidades | |
arquivo<- read_file("view_dados_abertos_fgts_agrupado_202411051721.csv") | |
#Remove as aspas duplas | |
arquivo_trabalho <- str_remove_all(arquivo,'"') | |
#Gera um novo arquivo csv | |
write_lines(arquivo_trabalho, "moradias_convertido.csv") | |
#GEra o dataframe |
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(tidyverse) | |
##Gráficos | |
library(sf) | |
library(spData) | |
library(colorspace) | |
de_para_nome_codigo_pais <- read_csv("de_para_nome_codigo_pais.csv") |
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
####Aqui a função | |
processa_ws_sp_chamada<- function(ano, | |
codOrgao = "Detalhado", #Consolidado/Detalhado/<Código> | |
CodFonte = "Detalhado", #Consolidado/Detalhado/<Código> | |
CodFuncao="Detalhado", #Consolidado/Detalhado/<Código> | |
CodGrupo="Todos", #Todos/<Código> | |
CodModalidade = "Todos")#Todos/<Código> | |
{ | |
# Carregar o pacote necessário |
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
resultado_eleicao_2024 <- read_delim("20241007_151828_eleicao24_prefeitos_vereadores_finalizados.csv", | |
delim = ";", escape_double = FALSE, trim_ws = TRUE) | |
candidatos_prefeitos_resultado<- | |
resultado_eleicao_2024 %>% | |
filter(cargo == "Prefeito") %>% | |
select(sg_partido, situacao_candidato_turno) | |
teste_chisq<- | |
chisq.test(candidatos_prefeitos_resultado$sg_partido, candidatos_prefeitos_resultado$situacao_candidato_turno,simulate.p.value = TRUE ) |
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(tidyverse) | |
library(geobr) | |
library(sf) | |
library(colorspace) | |
estados_sf<- geobr::read_state() | |
resultado_eleicao_2024 <- read_delim("20241007_151828_eleicao24_prefeitos_vereadores_finalizados.csv", | |
delim = ";", escape_double = FALSE, trim_ws = TRUE) |
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
#Simulação Toledo | |
gasto_primeira_mediana<- 2.5e6 * 100 | |
gasto_segunda_mediana_ate_2499000 <- 2499000 *681 | |
gasto_valores_pico<- 3e9 - (gasto_primeira_mediana + gasto_segunda_mediana_ate_2499000 ) | |
aposta_unitaria<- gasto_valores_pico / 1000 | |
media_simulacao<- (gasto_primeira_mediana + gasto_segunda_mediana_ate_2499000 + gasto_valores_pico)/5e6 |
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(ipeadatar) | |
library(tidyverse) | |
library(readxl) | |
series_disponiveis<- | |
ipeadatar::available_series() | |
codigos<- | |
((series_disponiveis %>% |
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
domicilio_municipios_tipo_abastecimento_agua<- | |
get_sidra(x = 6804, | |
variable = c(1000381), | |
#period = c("last" = 12), | |
geo = "City", | |
#geo.filter = "RS", | |
classific = "c301", | |
category = list(c(31471)), | |
header = FALSE, | |
format = 3) |
NewerOlder