Skip to content

Instantly share code, notes, and snippets.

@jeanmanguy
Last active April 29, 2017 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeanmanguy/ab05f7fe1f68c9e95b1d5fd5a2a392c3 to your computer and use it in GitHub Desktop.
Save jeanmanguy/ab05f7fe1f68c9e95b1d5fd5a2a392c3 to your computer and use it in GitHub Desktop.
Cleaning and tidying of the French presidential election 2017 official results (1st round)
library(purrr)
library(dplyr)
library(tidyr)
library(readr)
PR17_BVot_T1_FE <- read_csv2(
file = "https://www.data.gouv.fr/fr/datasets/r/8fdb0926-ea9d-4fb4-a136-7767cd97e30b",
locale = locale("fr", encoding = "iso-8859-1"),
col_names = FALSE,
skip = 1
) %>%
rename(
"Code du département" = X1,
"Libellé du département" = X2,
"Code de la circonscription" = X3,
"Code de la commune" = X5,
"Libellé de la commune" = X6,
"Code du bureau de vote" = X7,
"Inscrits" = X8,
"Votants" = X11,
"Blancs" = X13,
"Nuls" = X16,
"Exprimés" = X19,
"Nicolas DUPONT-AIGNAN" = X26,
"Marine LE PEN" = X33,
"Emmanuel MACRON" = X40,
"Benoît HAMON" = X47,
"Nathalie ARTHAUD" = X54,
"Philippe POUTOU" = X61,
"Jacques CHEMINADE" = X68,
"Jean LASSALLE" = X75,
"Jean-Luc MÉLENCHON" = X82,
"François ASSELINEAU" = X89,
"François FILLON" = X96
) %>%
select(-starts_with("X")) %>%
gather("candidat", "voix", `Nicolas DUPONT-AIGNAN`:`François FILLON`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment