Package 'infoelectoral'

Title: Download Spanish Election Results
Description: Download official election results for Spain at polling station, municipality and province level from the Ministry of Interior (<https://infoelectoral.interior.gob.es/es/elecciones-celebradas/area-de-descargas/>), format them and import them to the R environment.
Authors: Héctor Meleiro [aut, cre]
Maintainer: Héctor Meleiro <[email protected]>
License: GPL-2
Version: 1.0.2
Built: 2024-11-08 05:45:19 UTC
Source: https://github.com/rOpenSpain/infoelectoral

Help Index


Download candidate data

Description

'candidatos()' downloads, formats and imports to the environment the data of the candidates from the electoral lists of the selected elections.

Usage

candidatos(tipo_eleccion, anno, mes, nivel)

Arguments

tipo_eleccion

The type of choice you want to download. The accepted values are "congreso", "senado", "europeas" o "municipales".

anno

The year of the election in YYYY format.

mes

The month of the election in MM format.

nivel

The administrative level for which the data is wanted ("mesa" for polling stations or "municipio" for municipalities). Only necessary when tipo_eleccion = "senado"

Value

data.frame with the candidates data. If tipo_eleccion = "senado" a column called 'votos' is included with the votes recieved by each candidate. If other type of election is selected this column is not included since the votes are not received by the specific candidates but by the closed list of the party.

Examples

data <- candidatos(
  tipo_eleccion = "senado", anno = "2004",
  mes = "03", nivel = "municipio"
)
str(data)

Administrative codes for spanish autonomous communities.

Description

This dataset contains the codes given to the autonomus communities by the Ministry of Interior and the ones given by the National Institute of Statistics with their official names.

Usage

codigos_ccaa

Format

A dataset with 19 rows and 3 columns:

codigo_ccaa

Code given to the autonomous communities by the Ministry of Interior (not the same as the National Institute of Statistics codes)

codigo_ccaa_ine

Code given to the autonomous communities by the National Institute of Statistics

provincia

Official name of the provinces

Source

https://infoelectoral.interior.gob.es/opencms/es/elecciones-celebradas/area-de-descargas/


Administrative codes for spanish municipalities.

Description

This dataset contains the INE codes of the municipalities of Spain with their most recent names (eg: Cabrera d'Igualada appears as Cabrera d'Anoia). For the municipalities that have been merged at some point, their codes are kept separately along with that of the new municipality created (eg: it contains the municipality Oza-Cesuras but also that of Cesuras and Oza dos Ríos separately).

Usage

codigos_municipios

Format

A dataset with more than 8.000 rows and 3 columns:

codigo_provincia

Code given to the provinces by the National Institute of Statistics

codigo_municipio

Code given to the municipalities by the National Institute of Statistics

municipio

Most recent official name of the municipality

Source

https://www.ine.es/dyngs/INEbase/es/operacion.htm?c=Estadistica_C&cid=1254736177031&menu=ultiDatos&idp=1254734710990


Recoded party names

Description

This dataset contains a list of recoded electoral party or coalition names with their correspondent national codes. For example: 'PSOE' when the original name is 'PSA-PSOE', 'PSOE-PROGR.' or 'PSOE-A'. This recodification helps the longitudinal analysis of the electoral results, avoiding the many variations in the party and coalition names.

Usage

codigos_partidos

Format

A dataset with the names of the electoral party or coalition

anno

Year of the election

mes

Month of the election

codigo_partido_nacional

The national accumulation code for the electoral party or coalition

partido

The recoded name for the electoral party or coalition.


Administrative codes for spanish provinces.

Description

This dataset contains the National Institute of Statistics administrative codes for spanish provinces with their official names.

Usage

codigos_provincias

Format

A dataset with 52 rows and 5 columns:

codigo_ccaa

Code given to the autonomous communities by the Ministry of Interior (not the same as the National Institute of Statistics codes)

codigo_ccaa_ine

Code given to the autonomous communities by the National Institute of Statistics

ccaa

Official name of the autonomous communities

codigo_provincia

Code given to the provinces by the National Institute of Statistics

provincia

Official name of the provinces

Source

https://www.ine.es/daco/daco42/codmun/cod_provincia.htm


Election dates

Description

This dataset contains the dates of the local, general and european elections in Spain from 1977 to 2023.

Usage

fechas_elecciones

Format

A dataset with the dates of the elections

tipo_eleccion

Election level (local, general or european parliament)

anno

Year of the election

mes

Month of the election

day

Day of the election

Source

https://www.juntaelectoralcentral.es/cs/jec/elecciones


Download data at the polling station level

Description

'mesas()' downloads, formats and imports to the environment the electoral results data of the selected election at the polling station level.

Usage

mesas(tipo_eleccion, anno, mes)

Arguments

tipo_eleccion

The type of choice you want to download. The accepted values are "congreso", "senado", "europeas" o "municipales".

anno

The year of the election in YYYY format.

mes

The month of the election in MM format.

Value

data.frame with the electoral results data at the polling station level.

Examples

data <- mesas(tipo_eleccion = "congreso", anno = "2023", mes = "07")
  str(data)

Download data at the municipality level

Description

'municipios()' downloads, formats and imports to the environment the electoral results data of the selected election at the municipality level.

Usage

municipios(tipo_eleccion, anno, mes, distritos = FALSE)

Arguments

tipo_eleccion

The type of choice you want to download. The accepted values are "congreso", "senado", "europeas" o "municipales".

anno

The year of the election in YYYY format.

mes

The month of the election in MM format.

distritos

Should district level results be returned when available? The default is FALSE. Please be aware when summarizing the data that districts = TRUE will return separate rows for the total municipal level and for each of the districts.

Value

Dataframe with the electoral results data at the municipality level.

Examples

data <- municipios(tipo_eleccion = "congreso", anno = "2019", mes = "11")
str(data)

Download data at the electoral constituency level (province or island)

Description

'provincias()' downloads, formats and imports to the environment the electoral results data of the selected election at electoral constituency level (province or island).

Usage

provincias(tipo_eleccion, anno, mes)

Arguments

tipo_eleccion

The type of choice you want to download. The accepted values are "congreso", "senado", "europeas" o "municipales".

anno

The year of the election in YYYY format.

mes

The month of the election in MM format.

Value

data.frame with the electoral results data at the polling station level.

Examples

data <- provincias(tipo_eleccion = "congreso", anno = "1982", mes = "10")
str(data)

Mean income at the census section level (INE)

Description

This dataset contains the mean income of each census section

Usage

renta

Format

A dataset with more than 34.000 rows and 2 columns:

codigo_seccion

Code given to the census section made by the combination of the codes of the province, the municipality, the district and the section.

renta

Mean income of the census section in euros

Source

https://www.ine.es/dyngs/INEbase/es/operacion.htm?c=Estadistica_C&cid=1254736177088&menu=ultiDatos&idp=1254735976608