diff --git a/README.md b/README.md index f186fa3..902a877 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ [infoelectoral](https://ropenspain.github.io/infoelectoral/) is a R library that helps retrieve official electoral results for Spain from the [Ministry of the Interior](https://infoelectoral.interior.gob.es/opencms/es/inicio/). It allows you to download the results of general, european and municipal elections of any year at the polling station and municipality level. -# Installation +## Installation -``` R +``` r # To install the latest stable version from CRAN: install.packages("infoelectoral") @@ -18,7 +18,7 @@ install.packages("infoelectoral") devtools::install_github("ropenspain/infoelectoral") ``` -# Overview +## Overview [infoelectoral](https://ropenspain.github.io/infoelectoral/) has four functions: @@ -29,14 +29,14 @@ devtools::install_github("ropenspain/infoelectoral") The package also includes some [datasets](https://ropenspain.github.io/infoelectoral/reference/index.html#datasets) with the official names of the territorial units and the election dates. -# Basic usage +## Basic usage -``` R +``` r library(infoelectoral) df <- municipios(tipo_eleccion = "congreso", anno = 1982, mes = "10") ``` -# Learn more +## Learn more For a a extended example of how all functions work please check the vignettes: diff --git a/vignettes/municipios.Rmd b/vignettes/municipios.Rmd index 8044e11..7800573 100644 --- a/vignettes/municipios.Rmd +++ b/vignettes/municipios.Rmd @@ -42,7 +42,7 @@ shp_ccaa <- mapSpain::esp_get_ccaa() ``` -## Recode the party names +## Recode party names Since most parties have different names throughout the country, you will need to recode them to group their results. You can use the column `codigo_partido_nacional` included in the resulting `data.frame` that indicates the grouping party code at the national level. After that you'll have to create the complete municipality code (`LAU_CODE`) for the merge with the `sf` object and transform the data from long to wide format. First, let's group the parties by `codigo_partido_nacional` and `siglas` and sum the votes to see which party codes correspond to the main parties. @@ -80,8 +80,8 @@ results <- ``` -## Join the voting data to the geometries -With the `LAU_CODE` column merge the data with the geomtries of the municipalities. +## Join data and sf object +With the `LAU_CODE` column merge the data with the geometries of the municipalities. ```{r} shp <- left_join(shp, results, by = "LAU_CODE") @@ -111,7 +111,7 @@ maps <- ) + geom_sf( data = shp_ccaa, fill = NA, color = "black", - linewidth = 0.01 + linewidth = 0.1 ) + facet_wrap(~siglas_r) + scale_fill_gradient(