jeanmanguy
4/29/2017 - 5:46 PM

Cleaning and tidying of the French presidential election 2017 official results (1st round)

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`)