43 distritos
library(rio)
dataexa=import("https://docs.google.com/spreadsheets/d/1ske_yHt4tOcCK0h1aPZnd2EP6zM9Sv8Q/edit#gid=40790052")
head(dataexa)
## V1 V2 V3
## 1 TASA DE DENUNCIAS POR COMISION DE DELITOS,SEGUN DISTRITO
## 2 (Tasa por cada 10 000 habitantes)
## 3
## 4 Per?o 2022
## 5 Distrito
## 6 150101 LIMA 642,7
Residuos municipales de los 43 distritos de Lima:
dataresi=import("residuosPeru.xlsx")
## New names:
## • `` -> `...2`
## • `` -> `...3`
## • `` -> `...4`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
## • `` -> `...14`
## • `` -> `...15`
head(dataresi)
## Residuos municipales generados anualmente ...2 ...3 ...4 ...5
## 1 FECHA_CORTE N_SEC UBIGEO REG_NAT DEPARTAMENTO
## 2 20230614 1 10101 SELVA AMAZONAS
## 3 20230614 2 10102 SELVA AMAZONAS
## 4 20230614 3 10103 SIERRA AMAZONAS
## 5 20230614 4 10104 SIERRA AMAZONAS
## 6 20230614 5 10105 SIERRA AMAZONAS
## ...6 ...7 ...8 ...9 ...10 ...11 ...12
## 1 PROVINCIA DISTRITO POB_TOTAL POB_URBANA POB_RURAL GPC_DOM QRESIDUOS_DOM
## 2 CHACHAPOYAS CHACHAPOYAS 28423 27548 875 0.48 4857.5
## 3 CHACHAPOYAS ASUNCION 291 151 140 0.61 33.56
## 4 CHACHAPOYAS BALSAS 1615 299 1316 0.45 48.96
## 5 CHACHAPOYAS CHETO 597 388 209 0.45 63.59
## 6 CHACHAPOYAS CHILIQUIN 737 197 540 0.45 32.38
## ...13 ...14 ...15
## 1 QRESIDUOS_NO_DOM QRESIDUOS_MUN PERIODO
## 2 2081.78 6939.28 2014
## 3 14.38 47.95 2014
## 4 20.98 69.95 2014
## 5 27.25 90.84 2014
## 6 13.88 46.26 2014
Resultado por distrito:
library(rvest)
link = "https://es.wikipedia.org/wiki/Elecciones_municipales_de_Lima_de_2022#Resultados_por_distrito"
path = '//*[@id="mw-content-text"]/div[1]/table[9]/tbody'
dataresul <- read_html(link)%>%html_nodes(xpath = path)%>%html_table()%>% .[[1]]
head(dataresul)
## # A tibble: 6 × 17
## Distrito RP RP PP PP SP SP FE FE APP APP JP
## <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 Distrito "" "" "" "" "" "" "" "" "" "" ""
## 2 Distrito "V" "%" "V" "%" "V" "%" "V" "%" "V" "%" "V"
## 3 Ancón "3,725" "13.2… "9,3… "33.… "5,9… "21.… "2,0… "7.2… "3,5… "12.… "1,6…
## 4 Ate "57,374" "17.4… "98,… "29.… "52,… "15.… "27,… "8.5… "26,… "7.9… "25,…
## 5 Barranco "11,604" "36.9… "5,7… "18.… "6,4… "20.… "2,7… "8.8… "2,1… "6.9… "1,6…
## 6 Breña "22,721" "31.1… "18,… "25.… "14,… "19.… "8,2… "11.… "2,4… "3.3… "3,8…
## # ℹ 5 more variables: JP <chr>, AvP <chr>, AvP <chr>, PL <chr>, PL <chr>
Integración de datos: 1er paso: limpieza de los datos dataexa:
library(stringr)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.1 ✔ purrr 1.0.1
## ✔ forcats 1.0.0 ✔ readr 2.1.5
## ✔ ggplot2 3.4.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ readr::guess_encoding() masks rvest::guess_encoding()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
df=data.frame(dataexa$V1)
dataexafinal=dataexa%>%
separate(V1,into = c("Ubigeo", "Distrito"), sep=" ")
## Warning: Expected 2 pieces. Additional pieces discarded in 35 rows [1, 2, 16, 18, 19,
## 20, 22, 25, 26, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, ...].
## Warning: Expected 2 pieces. Missing pieces filled with `NA` in 7 rows [3, 4, 5, 49, 50,
## 57, 60].
datasin=dataexafinal%>%
select(-V2)
datasinn=datasin%>%
slice(-c(1:5,49:61))
dataresul: Elecciones municipales de 2022 RP, PP y SP
dataresul1=dataresul%>%
select(1,3,7)
library(dplyr)
datafilresul=dataresul1%>%
slice(-c(1,2,46))
Datas finales: datafilresul datasinn dataresi
datacom=merge(datafilresul, datasinn)
datacom2=merge(dataresi,datacom)
Pregunta 1: QResiduos_no_dom tasa de denuncias Renovación popular PP o SP
Modelo 1
#modelo1=formula(dataresi$QRESIDUOS_NO_DOM~datasinn$V3+datafilresul$SP)
#regre1=lm(modelo1,data=datafilresul,dataresi, datasinn)
#summary(regre1)
Pregunta 2 Cantidad de residuos dominiciarios y la tasa de denuncias porcentaje de votos de RP Significancia de 10%