| Title: | Download Spanish Election Results |
|---|---|
| Description: | Download official election results for Spain at polling station, municipality and province level, format them and import them to the R environment. Data are provided by the Spanish Ministry of the Interior (<https://infoelectoral.interior.gob.es/es/inicio/>). |
| Authors: | Héctor Meleiro [aut, cre] |
| Maintainer: | Héctor Meleiro <[email protected]> |
| License: | GPL-2 |
| Version: | 1.0.3 |
| Built: | 2026-05-14 09:39:59 UTC |
| Source: | https://github.com/rOpenSpain/infoelectoral |
'candidatos()' downloads, formats and imports to the environment the data of the candidates from the electoral lists of the selected elections.
candidatos(tipo_eleccion, anno, mes, nivel)candidatos(tipo_eleccion, anno, mes, nivel)
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" |
data.frame with the candidates data, or NULL if the remote
resource is unavailable. 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.
data <- candidatos( tipo_eleccion = "senado", anno = "2004", mes = "03", nivel = "municipio" ) if (!is.null(data)) { str(data) }data <- candidatos( tipo_eleccion = "senado", anno = "2004", mes = "03", nivel = "municipio" ) if (!is.null(data)) { str(data) }
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.
codigos_ccaacodigos_ccaa
A dataset with 19 rows and 3 columns:
Code given to the autonomous communities by the Ministry of Interior (not the same as the National Institute of Statistics codes)
Code given to the autonomous communities by the National Institute of Statistics
Official name of the provinces
Ministry of the Interior election data download area.
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).
codigos_municipioscodigos_municipios
A dataset with more than 8.000 rows and 3 columns:
Code given to the provinces by the National Institute of Statistics
Code given to the municipalities by the National Institute of Statistics
Most recent official name of the municipality
National Statistics Institute (INE) municipality code portal.
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.
codigos_partidoscodigos_partidos
A dataset with the names of the electoral party or coalition
Year of the election
Month of the election
The national accumulation code for the electoral party or coalition
The recoded name for the electoral party or coalition.
This dataset contains the National Institute of Statistics administrative codes for spanish provinces with their official names.
codigos_provinciascodigos_provincias
A dataset with 52 rows and 5 columns:
Code given to the autonomous communities by the Ministry of Interior (not the same as the National Institute of Statistics codes)
Code given to the autonomous communities by the National Institute of Statistics
Official name of the autonomous communities
Code given to the provinces by the National Institute of Statistics
Official name of the provinces
https://www.ine.es/daco/daco42/codmun/cod_provincia.htm
This dataset contains the dates of the local, general and european elections in Spain from 1977 to 2023.
fechas_eleccionesfechas_elecciones
A dataset with the dates of the elections
Election level (local, general or european parliament)
Year of the election
Month of the election
Day of the election
https://www.juntaelectoralcentral.es/cs/jec/elecciones
'mesas()' downloads, formats and imports to the environment the electoral results data of the selected election at the polling station level.
mesas(tipo_eleccion, anno, mes)mesas(tipo_eleccion, anno, mes)
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. |
data.frame with the electoral results data at the polling station
level, or NULL if the remote resource is unavailable.
data <- mesas(tipo_eleccion = "congreso", anno = "2023", mes = "07") if (!is.null(data)) { str(data) }data <- mesas(tipo_eleccion = "congreso", anno = "2023", mes = "07") if (!is.null(data)) { str(data) }
'municipios()' downloads, formats and imports to the environment the electoral results data of the selected election at the municipality level.
municipios(tipo_eleccion, anno, mes, distritos = FALSE)municipios(tipo_eleccion, anno, mes, distritos = FALSE)
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. |
Dataframe with the electoral results data at the municipality level,
or NULL if the remote resource is unavailable.
data <- municipios(tipo_eleccion = "congreso", anno = "2019", mes = "11") if (!is.null(data)) { str(data) }data <- municipios(tipo_eleccion = "congreso", anno = "2019", mes = "11") if (!is.null(data)) { str(data) }
'provincias()' downloads, formats and imports to the environment the electoral results data of the selected election at electoral constituency level (province or island).
provincias(tipo_eleccion, anno, mes)provincias(tipo_eleccion, anno, mes)
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. |
data.frame with the electoral results data at the polling station
level, or NULL if the remote resource is unavailable.
data <- provincias(tipo_eleccion = "congreso", anno = "1982", mes = "10") if (!is.null(data)) { str(data) }data <- provincias(tipo_eleccion = "congreso", anno = "1982", mes = "10") if (!is.null(data)) { str(data) }
This dataset contains the mean income of each census section
rentarenta
A dataset with more than 34.000 rows and 2 columns:
Code given to the census section made by the combination of the codes of the province, the municipality, the district and the section.
Mean income of the census section in euros
National Statistics Institute (INE) income statistics portal.