-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmapa-das-votacoes-mes-a-mes.Rmd
123 lines (92 loc) · 2.65 KB
/
mapa-das-votacoes-mes-a-mes.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
title: "mapa-das-votacoes-mes-a-mes"
author: "Rodolfo Viana"
date: "09-11-2015"
output: html_document
---
Compara as posições dos deputados federais considerando os votos em cada proposição mês a mês.
```{r, warning=FALSE, message=FALSE}
library(ggplot2)
library(dplyr)
library(reshape2)
require(cluster)
require(scales)
require(FactoMineR)
source("R/camara-lib.R")
```
Carregando CSV com os votos dos deputados
```{r, warning=FALSE, message=FALSE}
votos <- ler_votos_de_ativos("votacoes.csv", corrigir_migracoes = FALSE)
# distinguir diferentes votações de uma mesma proposição
votos$num_pro <- paste0(votos$num_pro, "-", votos$id_votacao)
```
Formatação das datas
```{r}
votos$data <- as.Date(votos$data, format = "%d/%m/%Y")
votos$ano_votacao <- as.numeric(format(votos$data, format = '%Y'))
votos$mes <- as.numeric(format(votos$data, format = '%m'))
votos <- votos %>%
filter(ano_votacao >= 2015)
```
```{r}
library("googleVis")
mca_t <- geraMCA(filter(votos, mes <= 5))
mca_t$data <- as.Date(paste0("01/02/2015"), format = "%d/%m/%Y")
for(ate in 6:10){
mca <- geraMCA(filter(votos, mes <= ate))
mca$data <- as.Date(paste0("01/", ate, "/2015"), format = "%d/%m/%Y")
mca_t <- rbind(mca_t, mca)
}
mca_t$nome <- paste0(mca_t$nome, " - ", mca_t$partido, "/", mca_t$uf)
motion <- gvisMotionChart(mca_t,
idvar = "nome",
timevar = "data",
options = list(poiintSize = 1))
plot(motion)
```
```{r, fig.align='center'}
mca <- geraMCA(filter(votos, mes < 3))
p <- plotMCA(mca)
png("plot/evolucao_fevereiro.png", width = 800, height = 600)
p
dev.off()
mca <- geraMCA(filter(votos, mes < 4))
p <- plotMCA(mca)
png("plot/evolucao_marco.png", width = 800, height = 600)
p
dev.off()
mca <- geraMCA(filter(votos, mes < 5))
p <- plotMCA(mca)
png("plot/evolucao_abril.png", width = 800, height = 600)
p
dev.off()
mca <- geraMCA(filter(votos, mes < 6))
p <- plotMCA(mca)
png("plot/evolucao_maio.png", width = 800, height = 600)
p
dev.off()
mca <- geraMCA(filter(votos, mes < 7))
p <- plotMCA(mca)
png("plot/evolucao_junho.png", width = 800, height = 600)
p
dev.off()
mca <- geraMCA(filter(votos, mes < 8))
p <- plotMCA(mca)
png("plot/evolucao_julho.png", width = 800, height = 600)
p
dev.off()
mca <- geraMCA(filter(votos, mes < 9))
p <- plotMCA(mca)
png("plot/evolucao_agosto.png", width = 800, height = 600)
p
dev.off()
mca <- geraMCA(filter(votos, mes < 10))
p <- plotMCA(mca)
png("plot/evolucao_setembro.png", width = 800, height = 600)
p
dev.off()
mca <- geraMCA(filter(votos, mes < 11))
p <- plotMCA(mca)
png("plot/evolucao_outubro.png", width = 800, height = 600)
p
dev.off()