Skip to content

Instantly share code, notes, and snippets.

@jmcastagnetto
Last active January 28, 2020 21:30
Show Gist options
  • Save jmcastagnetto/9772ff6757c0adc108c0ae85970833af to your computer and use it in GitHub Desktop.
Save jmcastagnetto/9772ff6757c0adc108c0ae85970833af to your computer and use it in GitHub Desktop.
Gráfico simple de las tasas de ausentismo/abstencionismo electoral -- Elecciones Congreso 2020 (Perú)
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 1 column, instead of 5 in line 3.
#Participación Ciudadana Elecciones Congresales Extraordinarias 2020
#Ubigeo: TODOS
#ACTUALIZADO EL 27/01/2020 A LAS 12:08 h
#,PARTICIPACIÓN,,AUSENTISMO,
"DEPARTAMENTO/CONTINENTE","TOTAL ASISTENTES","% TOTAL ASISTENTES","TOTAL AUSENTES","% TOTAL AUSENTES","ELECTORES HÁBILES"
"AFRICA","0","0.00","0","0.00","0"
"AMAZONAS","157,470","63.68","89,827","36.32","247,297"
"AMERICA","0","0.00","0","0.00","0"
"ANCASH","570,090","73.25","208,165","26.75","778,255"
"APURIMAC","200,529","69.24","89,105","30.76","289,634"
"AREQUIPA","857,488","80.67","205,533","19.33","1,063,021"
"ASIA","0","0.00","0","0.00","0"
"AYACUCHO","243,178","68.89","109,830","31.11","353,008"
"CAJAMARCA","572,117","66.72","285,405","33.28","857,522"
"CALLAO","571,462","80.68","136,870","19.32","708,332"
"CUSCO","621,084","75.86","197,680","24.14","818,764"
"EUROPA","0","0.00","0","0.00","0"
"HUANCAVELICA","143,904","66.81","71,476","33.19","215,380"
"HUANUCO","319,542","66.08","164,044","33.92","483,586"
"ICA","518,237","82.40","110,700","17.60","628,937"
"JUNIN","635,061","74.88","213,093","25.12","848,154"
"LA LIBERTAD","850,987","74.66","288,757","25.34","1,139,744"
"LAMBAYEQUE","647,481","77.37","189,410","22.63","836,891"
"LIMA","4,168,565","80.64","1,000,874","19.36","5,169,439"
"LORETO","232,701","67.52","111,923","32.48","344,624"
"MADRE DE DIOS","71,406","72.44","27,163","27.56","98,569"
"MOQUEGUA","105,404","79.72","26,813","20.28","132,217"
"OCEANIA","0","0.00","0","0.00","0"
"PASCO","79,826","69.42","35,162","30.58","114,988"
"PIURA","883,768","75.58","285,529","24.42","1,169,297"
"PUNO","662,647","80.32","162,318","19.68","824,965"
"SAN MARTIN","339,533","70.28","143,592","29.72","483,125"
"TACNA","213,914","81.18","49,595","18.82","263,509"
"TUMBES","107,899","78.69","29,226","21.31","137,125"
"UCAYALI","203,911","71.66","80,654","28.34","284,565"
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 1 column, instead of 5 in line 3.
#Participación Ciudadana Elecciones Congresales Extraordinarias 2020
#Ubigeo: TODOS
#ACTUALIZADO EL 28/01/2020 A LAS 15:28 h
#,PARTICIPACIÓN,,AUSENTISMO,
"DEPARTAMENTO/CONTINENTE","TOTAL ASISTENTES","% TOTAL ASISTENTES","TOTAL AUSENTES","% TOTAL AUSENTES","ELECTORES HÁBILES"
"AFRICA","60","18.87","258","81.13","318"
"AMAZONAS","165,452","62.58","98,949","37.42","264,401"
"AMERICA","51,417","24.21","160,923","75.79","212,340"
"ANCASH","576,890","72.97","213,671","27.03","790,561"
"APURIMAC","200,529","69.24","89,105","30.76","289,634"
"AREQUIPA","862,651","80.42","210,017","19.58","1,072,668"
"ASIA","3,951","15.08","22,250","84.92","26,201"
"AYACUCHO","263,253","67.35","127,633","32.65","390,886"
"CAJAMARCA","635,122","66.41","321,251","33.59","956,373"
"CALLAO","571,462","80.68","136,870","19.32","708,332"
"CUSCO","678,854","74.17","236,391","25.83","915,245"
"EUROPA","11,614","27.76","30,219","72.24","41,833"
"HUANCAVELICA","169,622","64.87","91,876","35.13","261,498"
"HUANUCO","325,508","65.78","169,329","34.22","494,837"
"ICA","519,300","82.39","110,980","17.61","630,280"
"JUNIN","644,480","74.54","220,135","25.46","864,615"
"LA LIBERTAD","904,599","74.45","310,516","25.55","1,215,115"
"LAMBAYEQUE","647,966","77.37","189,556","22.63","837,522"
"LIMA","5,516,348","80.94","1,299,078","19.06","6,815,426"
"LORETO","298,141","62.09","182,024","37.91","480,165"
"MADRE DE DIOS","77,414","71.61","30,686","28.39","108,100"
"MOQUEGUA","105,506","79.72","26,848","20.28","132,354"
"OCEANIA","0","0.00","0","0.00","0"
"PASCO","118,584","66.72","59,142","33.28","177,726"
"PIURA","892,782","75.25","293,707","24.75","1,186,489"
"PUNO","675,390","80.18","166,980","19.82","842,370"
"SAN MARTIN","365,515","70.12","155,741","29.88","521,256"
"TACNA","213,914","81.18","49,595","18.82","263,509"
"TUMBES","107,899","78.69","29,226","21.31","137,125"
"UCAYALI","224,671","68.91","101,341","31.09","326,012"
# Fuente de datos (CSV): https://resultados.eleccionescongresales2020.pe/PRECE2020/Participacion/Detalle, 2020-01-27 12:08h
library(tidyverse)
continentes <- c(
"AFRICA",
"AMERICA",
"ASIA",
"EUROPA",
"OCEANIA"
)
df <- read_csv(
"Parti_ciu_TODOS_DETALLE.csv",
skip = 4
) %>%
janitor::clean_names() %>%
mutate(
continente = departamento_continente %in% continentes
) %>%
filter(!continente) %>%
rename(
departamento = departamento_continente
)
df2 <- df %>% arrange(desc(percent_total_ausentes))
ggplot(df2,
aes(x = fct_reorder(departamento, percent_total_ausentes),
y = percent_total_ausentes)) +
geom_col(fill = "red") +
geom_text(
aes(label = sprintf("%.1f%%", percent_total_ausentes)),
color = "white", hjust = 1, nudge_y = -1, size = 4,
fontface = "bold"
) +
coord_flip() +
labs(
title = "Alta tasa de ausentismo electoral en algunos Departamentos\nElecciones Congresales 2020 - Perú",
subtitle = "Fuente: ONPE, https://resultados.eleccionescongresales2020.pe/PRECE2020/Participacion/Detalle (2020-01-27, 12:08h)",
x = "",
y = "Porcentaje de Ausentismo/Abstencionismo",
caption = "@jmcastagnetto, Jesus M. Castagnetto"
) +
theme_minimal(18) +
theme(
plot.subtitle = element_text(size = 10)
)
@jmcastagnetto
Copy link
Author

20200128-ausentismo-electoral-congreso-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment