library(readxl)
votacao_2020_Duque_de_Caxias_1_ <- read_excel("votacao 2020 - Duque de Caxias (1).xlsx")
##Carregamento de Pacote
library(readxl)
library(readr)
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(kableExtra)
##
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
##
## group_rows
library(knitr)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ lubridate 1.9.5 ✔ tibble 3.3.1
## ✔ purrr 1.2.2 ✔ tidyr 1.3.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ kableExtra::group_rows() masks dplyr::group_rows()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(magrittr)
##
## Attaching package: 'magrittr'
##
## The following object is masked from 'package:purrr':
##
## set_names
##
## The following object is masked from 'package:tidyr':
##
## extract
library(rmarkdown)
library(tidyr)
eleicao <- votacao_2020_Duque_de_Caxias_1_
x <- eleicao %>%
group_by(nm_candidato) %>%
summarise(maximo_votos = max(qt_votos_nom_validos),
minimo_votos = min(qt_votos_nom_validos),
media_votos = mean(qt_votos_nom_validos),
mediana_votos = median(qt_votos_nom_validos),
S_votos = sd(qt_votos_nom_validos))
kable(head(x,20))
| nm_candidato | maximo_votos | minimo_votos | media_votos | mediana_votos | S_votos |
|---|---|---|---|---|---|
| ABRAAO SILVA DE MELLO | 359 | 7 | 60.428571 | 11 | 131.734401 |
| ADALBERTO ALMEIDA | 206 | 9 | 56.000000 | 31 | 68.500608 |
| ADEMAR OLIVEIRA PASSOS | 188 | 4 | 33.714286 | 7 | 68.199986 |
| ADEMIR JORGE DA SILVA | 168 | 5 | 32.000000 | 9 | 60.077727 |
| ADILSON DE OLIVEIRA | 72 | 2 | 15.285714 | 4 | 25.538953 |
| ADILSON MIRANDA DA SILVA | 329 | 1 | 56.285714 | 8 | 120.843858 |
| ADRIANA ANTUNES DE CERQUEIRA | 499 | 2 | 85.714286 | 13 | 183.229105 |
| ADRIANA BATISTA DE PAULO GALDINO DA SILVA | 151 | 2 | 29.571429 | 9 | 53.913069 |
| ADRIANA DA SILVA SEGUNDO | 33 | 1 | 15.571429 | 13 | 11.872337 |
| ADRIANA LIRA BASTOS | 33 | 1 | 7.000000 | 2 | 11.590226 |
| ADRIANA MARTINS DE ALMEIDA | 7 | 0 | 2.142857 | 1 | 3.023716 |
| ADRIANA REIS DE OLIVEIRA | 6 | 0 | 1.285714 | 1 | 2.138090 |
| ADRIANA RODRIGUES DAS DORES | 116 | 1 | 43.285714 | 38 | 43.488367 |
| ADRIANO DE OLIVEIRA PARREIRA BATISTA | 483 | 11 | 94.571429 | 26 | 172.485610 |
| ADRIANO MARTINS COSTA | 129 | 0 | 26.000000 | 6 | 46.833037 |
| ADRIANO RODRIGUES DE SOUZA | 625 | 20 | 141.142857 | 58 | 216.805926 |
| AFENES TEIXEIRA DOS SANTOS | 171 | 1 | 43.285714 | 18 | 60.146250 |
| AFONSO ATHAYDE DE OLIVEIRA | 99 | 0 | 16.857143 | 3 | 36.393354 |
| AGNALDO AQUINO DE OLIVEIRA | 101 | 3 | 20.714286 | 6 | 35.682462 |
| AGNALDO KRETTLI FERREIRA | 302 | 4 | 58.857143 | 25 | 107.700864 |
ggplot(eleicao) +
aes(qt_votos_nom_validos) +
geom_histogram(bins = 20, color = "green", fill = "yellow") +
facet_grid(~ds_sit_totalizacao)
## Gráfico de barras ## Nesse gráfico podemos observar a quantidade
detalhada e de forma decrescente a quantidade de votos em cada cargo e
situação.
Quantidade_por_cargo <- table(votacao_2020_Duque_de_Caxias_1_$ds_cargo)
Quantidade_por_cargo <- Quantidade_por_cargo[order(Quantidade_por_cargo, decreasing = TRUE)]
cores <- terrain.colors(Quantidade_por_cargo)
par(mar = c(9, 5, 4, 2))
bp <- barplot(Quantidade_por_cargo,
main = "Número de votos por cargo(base eleicao)",
ylab ="Quantidade de votos",
cex.axis = 0.7,
col = cores,
border = "darkgray",
las = 2,
cex.names = 0.8,
ylim = c(0, max(Quantidade_por_cargo) * 1.2))
grid(nx = NA, ny = NULL, col = "gray", lty = "dotted")
text(x = bp ,
y = Quantidade_por_cargo,
label = Quantidade_por_cargo,
pos = 3,
cex = 0.7,
col = "darkblue",
font = 2)