Skip to content

Instantly share code, notes, and snippets.

View gabrielzanlorenssi's full-sized avatar
🐊

Gabriel Zanlorenssi gabrielzanlorenssi

🐊
View GitHub Profile
@gabrielzanlorenssi
gabrielzanlorenssi / .R
Last active September 3, 2019 21:51
Calculando margem de erro
### calculando margem de erro
# p = probabilidade
# n = tamanho da amostra
# z = 1.96 para 95% de confiança em um teste bicaudal
# base = 1 para probabilidades de 0 a 1, ou 100 para probabilidades de 0 a 100
margem <- function(p, n, z=1.96, base=1) {
Margem = z * base * sqrt((p/base * (1-(p/base)))/n)
return(Margem)
## Code to generate divida liquida plots
# Library -----------------------------------------------------------------
library(tidyverse)
library(readxl)
library(lubridate)
# Data --------------------------------------------------------------------
library(readxl)
library(tidyverse)
library(ggrepel)
# Data -------------------------------------------------------------------
# data here https://docs.google.com/spreadsheets/d/11bv5VB6Hyz0BeWBWPiVoE-mlvOm9kB6jbCHGdjaz27Q/edit?usp=sharing
gini <- read_excel("~/Downloads/gini.xlsx", sheet="Sheet4")
# Setwd -------------------------------------------------------------------
setwd("605. Picadas de animais/")
# Libraries ---------------------------------------------------------------
library(tidyverse)
library(readxl)
# Libraries ---------------------------------------------------------------
library(congressbr)
library(tidyverse)
library(lubridate)
# Bills -------------------------------------------------------------------
#--- libraries
library(readxl)
library(sf)
library(tidyverse)
#--- data
pib <- read_excel("pib.xlsx") %>%
mutate(code = as.numeric(code))
##-- GABRIEL ZANLORENSSI
##-- 01/04/2020
# Bibliotecas -------------------------------------------------------------
library(readxl)
library(tidyverse)
library(lubridate)
@gabrielzanlorenssi
gabrielzanlorenssi / codigo.r
Created March 29, 2021 19:50
Código de R para calcular a extensão das fronteiras dos estados brasileiros
# Bibliotecas -------------------------------------------------------------
library(tidyverse)
library(sf)
library(sp)
library(rgeos)
# devtools::install_github("Nexo-Dados/nexo.utils")
library(nexo.utils)
@gabrielzanlorenssi
gabrielzanlorenssi / codigo_ipec.r
Last active September 5, 2022 01:16
codigo_pesquisas_ipec
# 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)
#-- 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",