Skip to content

Instantly share code, notes, and snippets.

@DATAUNIRIO
Created December 2, 2021 18:36
Show Gist options
  • Save DATAUNIRIO/5db2e078721208f492f6c9cb89d8f109 to your computer and use it in GitHub Desktop.
Save DATAUNIRIO/5db2e078721208f492f6c9cb89d8f109 to your computer and use it in GitHub Desktop.
library(readr)
QE <- read_csv('https://raw.githubusercontent.com/DATAUNIRIO/Base_de_dados/master/QE.csv')
names(QE)
plot(QE$Horas_estudo,QE$Estresse)
abline(lsfit(QE$Horas_estudo,QE$Estresse),col="red")
modelo <- lm(Estresse~Horas_estudo,data=QE)
summary(modelo)
residuos <- residuals(modelo)
qqnorm(residuos)
qqline(residuos)
library(gvlma)
gvmodel <- gvlma(modelo)
summary(gvmodel)
bd_he <- data.frame(
Horas_estudo = c(12,55, 19, 24))
predict(modelo,bd_he)
predict(modelo,bd_he, interval = "confidence")
library(ggplot2)
url_do_arquivo <- "https://github.com/DATAUNIRIO/Base_de_dados/raw/master/BasesEstados.xlsx"
download.file(url_do_arquivo,"BasesEstados.xlsx",mode="wb") # windows
library(readxl)
BasesEstados <- read_excel("BasesEstados.xlsx")
# Import -----------------------------------------------------------------------
mapa_estados <- geobr::read_state()
#plot(mapa_estados)
# Tidy -------------------------------------------------------------------------
library(dplyr)
dados_brutos <- dados_brutos %>% rename(code_state=Codigo)
dados_brutos$code_state<- as.numeric(dados_brutos$code_state)
names(dados_brutos)
dados_mapa <- mapa_estados %>% left_join(dados_brutos)
remove(mapa_estados,dados_brutos)
# Visualize --------------------------------------------------------------------
ggplot() +
geom_sf(data=dados_mapa, aes(fill=IDH)) +
scale_fill_distiller(palette = "Oranges",direction = 1, name="IDH", limits = c(0.6,1))
library(leaflet)
leaflet_map <- dados_mapa %>%
leaflet() %>% addPolygons(color = "#444444",
fillColor = ~colorQuantile("YlOrRd", IDH)(IDH)),
leaflet_map
leaflet_map %>% addProviderTiles(providers$Esri.WorldImagery)
leaflet_map %>% addProviderTiles(providers$CartoDB.Positron)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment