Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Cazelles committed May 8, 2017
1 parent 6c0f77d commit 97db563
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
21 changes: 11 additions & 10 deletions R/mapElections.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ library(htmlwidgets)
library(htmltools)
library(leaflet)
library(rgdal)
library(highcharter)

##
##
wrld_adm <- readRDS("data/worldsimpleready.Rds")

## Remove France
Expand All @@ -30,15 +31,15 @@ for (i in 1:nbc) {
id <- which(rk2 == j)
vot <- wrld_adm@data[i, id + 4]
pct <- round(100 * vot/wrld_adm@data$voteTot[i], 2)
ls_labels[i] %<>% paste0("<br><strong>", j, ".</strong> ", names(wrld_adm@data)[id +
ls_labels[i] %<>% paste0("<br><strong>", j, ".</strong> ", names(wrld_adm@data)[id +
4], " : ", vot, " soit ", pct, "%")
}
}
}
ls_labels %<>% lapply(htmltools::HTML)

## COLORS (only 4 winners...)
vec_col <- c("white", "#232f70", "#232f70", "#01b2fb", "#97c121", "#c9462c", "#c9462c",
vec_col <- c("white", "#232f70", "#232f70", "#01b2fb", "#97c121", "#c9462c", "#c9462c",
"#232f70", "#c9462c", "#c9462c", "#232f70", "#c9a00e")
ls_col <- vec_col[vec_pos + 1] %>% as.list

Expand All @@ -47,15 +48,15 @@ ls_col <- vec_col[vec_pos + 1] %>% as.list

## Creating the Map using leaflet;
cat("\n---- CREATING THE MAP ----\n")
map_elec <- leaflet(wrld_adm) %>% setView(lng = 5, lat = 10, zoom = 3) %>% addTiles() %>%
addPolygons(weight = 2, opacity = 1, color = ls_col, dashArray = "3", fillOpacity = 0.7,
highlight = highlightOptions(weight = 3, color = "#666", dashArray = "",
fillOpacity = 0.7, bringToFront = TRUE), label = ls_labels, labelOptions = labelOptions(style = list(`font-weight` = "normal",
padding = "3px 8px"), textsize = "15px", direction = "auto")) %>% addEasyButton(easyButton(icon = "fa-github-square fa-2x",
title = "View source code", onClick = JS("function(btn){window.location.href = 'https://github.com/letiR/Elections_fr-042017';}"),
map_elec <- leaflet(wrld_adm) %>% setView(lng = 5, lat = 10, zoom = 3) %>% addTiles() %>%
addPolygons(weight = 2, opacity = 1, color = ls_col, dashArray = "3", fillOpacity = 0.7,
highlight = highlightOptions(weight = 3, color = "#666", dashArray = "",
fillOpacity = 0.7, bringToFront = TRUE), label = ls_labels, labelOptions = labelOptions(style = list(`font-weight` = "normal",
padding = "3px 8px"), textsize = "15px", direction = "auto")) %>% addEasyButton(easyButton(icon = "fa-github-square fa-2x",
title = "View source code", onClick = JS("function(btn){window.location.href = 'https://github.com/letiR/Elections_fr-042017';}"),
position = "topright")) %>% addProviderTiles(providers$Esri.WorldImagery)


##
##
cat("\n---- SAVING THE MAP ----\n")
saveWidget(widget = map_elec, file = "index.html")
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Elections_fr-042017

Cartographie du vote des français de l'étranger - 1er Tour - 2017

Carte réalisée avec Leaflet (appelé via R, voir les packages utilisés ci-dessous et la [documentation](https://rstudio.github.io/leaflet/)).
Expand All @@ -12,27 +13,26 @@ https://www.data.gouv.fr/fr/datasets/resultats-du-vote-des-francais-residant-a-l
- Données pour les frontières administratives sont disponibles en ligne, nous avons utilisé la version 2.8 de GADM [GADM](ttp://www.gadm.org/version2). Nous avons simplement simplifié ces données pour les rendre plus légères (function `gSimplify()` du package R `rgeos`, voir le fichier `simpleWorld.R`).


## Packages R requis
## Liste des Packages R requis

1. magrittr
1. htmlwidgets
1. htmltools
1. leaflet
1. countrycode
1. rgdal
1. stringdist

```r
library(magrittr)
library(htmlwidgets)
library(htmltools)
library(leaflet)
library(countrycode)
library(rgdal)
library(stringdist)
```

## TODO

- [X] merger les résultats du Kosovo avec la Serbie;
- [X] merger les résultats de Jérusalem avec Israël;
- [X] couleur pour le gagnant;
- [X] détails des résultats;
- [ ] faire la France?;
- [ ] Inverser les couleurs entre le candidat macron et fillon (http://www.lemonde.fr/les-decodeurs/article/2017/04/26/presidentielle-les-francais-de-l-etranger-ont-vote-macron-a-40-au-premier-tour_5117947_4355770.html)
- [ ] Ajouter une légende
- [ ] Ajouter le titre
- [X] faire la France => voir https://github.com/letiR/fr-departement-election
- [ ] Inverser les couleurs entre le candidat macron et fillon (http://www.lemonde.fr/les-decodeurs/article/2017/04/26/presidentielle-les-francais-de-l-etranger-ont-vote-macron-a-40-au-premier-tour_5117947_4355770.html) NB
on change sur la prochaine carte
- [X] Ajouter une légende
- [X] Ajouter le titre
- [ ] Ajouter les couches par candidats
- [ ] on pourrait faire un score gauche/droite et un score système/anti-système (Je pense que ca forcerait l'interprétation (SV).)

0 comments on commit 97db563

Please sign in to comment.