This file contains 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) | |
library(readxl) | |
library(rvest) | |
library(httr) | |
library(xml2) | |
library(lubridate) | |
library(sf) | |
# Scrap API --------------------------------------------------------------- |
This file contains 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
# Resultados copa --------------------------------------------------------- | |
library(tidyverse) | |
library(readxl) | |
library(googlesheets4) | |
url = "https://docs.google.com/spreadsheets/d/1m9fPRyk5fNVP7CXuVw2MqF3ZGAMbFFhceTsEoYSCUy4/edit#gid=0" | |
sheets <- read_sheet(url) |
This file contains 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
# Pacotes ----------------------------------------------------------------- | |
library(tidyverse) | |
library(jsonlite) | |
# Configurar -------------------------------------------------------------- | |
#-- codigo pleito | |
# pleito = 544 # 1t !! (usar esse para teste) !! |
This file contains 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
# Pacotes ----------------------------------------------------------------- | |
library(tidyverse) | |
library(jsonlite) | |
# Configurar -------------------------------------------------------------- | |
#-- codigo pleito |
This file contains 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
# Pacotes ----------------------------------------------------------------- | |
library(tidyverse) | |
library(jsonlite) | |
# Configuracao dos municipios --------------------------------------------- | |
urlm = "https://resultados.tse.jus.br/oficial/ele2022/544/config/mun-e000544-cm.json" |
This file contains 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(rvest) | |
library(tidyverse) | |
#-- links | |
url = "https://www.camara.leg.br/internet/sitaqweb/resultadoPesquisaDiscursos.asp?txIndexacao=&CurrentPage=19&BasePesq=plenario&txOrador=JAIR%20BOLSONARO&txPartido=&dtInicio=&dtFim=&txUF=&txSessao=&listaTipoSessao=&listaTipoInterv=&inFalaPres=&listaTipoFala=&listaFaseSessao=&txAparteante=&listaEtapa=&CampoOrdenacao=dtSessao&TipoOrdenacao=DESC&PageSize=50&txTexto=&txSumario=" | |
url %>% | |
read_html(url) %>% | |
html_nodes("a") %>% |
This file contains 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
# Bibliotecas ------------------------------------------------------------- | |
library(tidyverse) | |
library(sf) | |
library(jsonlite) | |
# Configuracao dos municipios --------------------------------------------- | |
urlm = "https://resultados.tse.jus.br/oficial/ele2022/544/config/mun-e000544-cm.json" | |
muni_tse <- fromJSON(urlm, |
This file contains 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 ----------------------------------------------------------------- | |
library(cepespR) | |
library(tidyverse) | |
#-- 1998 a 2018 | |
years <- c(1998, 2002, 2006, 2010, 2014, 2018) | |
d <- map_df(years, function(x) { | |
get_votes(year=x, position="President") %>% |
This file contains 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
#-- exemplo | |
cidade = "SÃO PAULO" | |
uf = "SP" | |
final %>% | |
mutate(partido = case_when(partido %in% c("PT", "PSDB", "PSOL") ~ partido, | |
numero_cand == 17 & year==2018 ~ "Bolsonaro", | |
numero_cand == 20 & year==1989 ~ "Collor", | |
numero_cand == 12 & year<1998 ~ "Brizola", |
This file contains 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
# atenção: código escrito rapidamente. não foi revisado para deixar mais legível | |
# Library ----------------------------------------------------------------- | |
library(tidyverse) | |
library(sf) | |
library(readxl) | |
library(googlesheets4) | |
library(geobr) |
NewerOlder