Skip to contents

Search and import data directly to R from the Spanish Sociological Research Center (CIS). The CIS is a public institution that conducts electoral and sociological research studies on the Spanish society. The CIS has a large database of surveys that can be accessed through its website. The package includes functions to search for surveys, survey questions and timeseries, and import the data directly to R.

Installation

You can install opencis from Github using the devtools package:

devtools::install_github("hmeleiro/opencis")

Usage

The package includes two functions.

The first function is used to search for surveys, survey questions and data series

# Search for survey studies
library(opencis)

# Search for survey studies
search_cis(q = "preelectoral", from = "2020-01-01", to = "2023-11-17")

#> # A tibble: 27 × 4
#>    study   date       title                                                              url  
#>    <chr>   <date>     <chr>                                                              <chr>
#>  1 3411    2023-06-08 Preelectoral elecciones generales 2023                             http…
#>  2 3402    2023-04-10 Preelectoral elecciones municipales y autonómicas 2023             http…
#>  3 3306    2021-01-02 Preelectoral de Cataluña. Elecciones autonómicas 2021              http…
#>  4 3317    2021-03-19 Preelectoral elecciones autonómicas 2021. Comunidad de Madrid      http…
#>  5 3287    2020-06-10 Preelectoral de Galicia. Elecciones autonómicas julio 2020         http…
#>  6 3276    2020-02-17 Preelectoral de Galicia. Elecciones autonómicas abril 2020         http…
#>  7 3286    2020-06-10 Preelectoral del País Vasco. Elecciones autonómicas julio 2020     http…
#>  8 3275    2020-02-17 Preelectoral del País Vasco. Elecciones autonómicas abril 2020     http…
#>  9 3365    2022-05-17 Preelectoral elecciones autonómicas 2022. Comunidad autónoma de A… http…
#> 10 3348    2022-01-07 Preelectoral elecciones autonómicas 2022. Comunidad autónoma de C… http…
#> # ℹ 17 more rows
#> # ℹ Use `print(n = ...)` to see more rows


# Search for survey questions
search_cis(q = "feminismo", catalogo = "pregunta")

#> # A tibble: 8 × 4
#>   question             date       title                                                  url  
#>   <chr>                <date>     <chr>                                                  <chr>
#> 1 Pregunta 3428/0/0016 2023-11-06 Escala de autodefinición feminista (0-10)              http…
#> 2 Pregunta 2212/0/0008 1996-04-13 Sentimientos hacia diferentes ideologías, situaciones… http…
#> 3 Pregunta 2828/0/0010 2010-01-09 Rasgos ideológicos que definen a la derecha y a la iz… http…
#> 4 Pregunta 1993/0/0009 1992-02-27 Sentimientos hacia diferentes ideologías, situaciones… http…
#> 5 Pregunta 2401/0/0025 2000-12-09 Rasgos ideológicos que definen a la derecha y a la iz… http…
#> 6 Pregunta 3428/0/0010 2023-11-06 Aprobación de diferentes conductas pro-igualdad de gé… http…
#> 7 Pregunta 2016/0/0026 1992-07-09 Rasgos que definen a la derecha y a la izquierda polí… http…
#> 8 Pregunta 2154/0/0036 1995-04-03 Rasgos que definen a la derecha y a la izquierda polí… http…

# Search for data series
search_cis(q = "situación económica", catalogo = "serie")

#> # A tibble: 100 × 5
#>    serie               from       to         title                                                               url    
#>    <chr>               <date>     <date>     <chr>                                                               <chr>  
#>  1 Serie K.1.03.03.012 2011-11-21 2025-09-12 Situación económica familiar (ICC)                                  https:…
#>  2 Serie K.1.02.01.014 1992-11-13 2019-10-01 Valoración de la situación económica actual de España (Extremadura) https:…
#>  3 Serie K.1.02.01.008 1992-11-14 2019-06-17 Valoración de la situación económica actual de España (Cantabria)   https:…
#>  4 Serie K.1.02.01.003 1986-05-01 2019-10-01 Valoración de la situación económica actual de España (Andalucía)   https:…
#>  5 Serie K.1.02.01.004 1998-05-01 2019-10-01 Valoración de la situación económica actual de España (Aragón)      https:…
#>  6 Serie K.1.02.01.007 1998-05-01 2019-10-01 Valoración de la situación económica actual de España (Canarias)    https:…
#>  7 Serie K.1.02.01.019 1998-05-01 2015-05-29 Valoración de la situación económica actual de España (La Rioja)    https:…
#>  8 Serie K.1.02.01.011 1992-11-07 2020-03-01 Valoración de la situación económica actual de España (Cataluña)    https:…
#>  9 Serie K.1.03.01.012 2010-01-23 2017-09-21 Valoración de la situación económica personal actual (Andalucía)    https:…
#> 10 Serie K.1.03.01.020 1992-04-24 2025-10-01 Valoración de la situación económica personal actual (Nacional)     https:…
#> # ℹ 90 more rows
#> # ℹ Use `print(n = ...)` to see more rows

The second function is used to import the data directly into R.

# Read a survey study
df <- read_cis(3411)
print(df)

#> # A tibble: 29,201 × 216
#>    ESTUDIO     REGISTRO  CUES CCAA    PROV    MUN     CAPITAL TAMUNI  ENTREV  TIPO_TEL SEXO   
#>    <dbl+lbl>      <dbl> <dbl> <dbl+l> <dbl+l> <dbl+l> <dbl+l> <dbl+l> <dbl+l> <dbl+lb> <dbl+l>
#>  1 3411 [3411]   492777 29043 1 [And… 4 [Alm… 0 [Mun… 3 [Otr… 1 [Men… 0 [Ano… 2 [Móvi… 1 [Hom…
#>  2 3411 [3411]    70655  5848 1 [And… 4 [Alm… 0 [Mun… 3 [Otr… 1 [Men… 0 [Ano… 2 [Móvi… 2 [Muj…
#>  3 3411 [3411]    46423  3893 1 [And… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano… 2 [Móvi… 2 [Muj…
#>  4 3411 [3411]   103464  8711 1 [And… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano… 2 [Móvi… 2 [Muj…
#>  5 3411 [3411]   112810  9517 1 [And… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano… 2 [Móvi… 2 [Muj…
#>  6 3411 [3411]   126567 10736 1 [And… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano… 2 [Móvi… 1 [Hom…
#>  7 3411 [3411]   137692 11573 1 [And… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano… 2 [Móvi… 2 [Muj…
#>  8 3411 [3411]   182178 14839 1 [And… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano… 2 [Móvi… 2 [Muj…
#>  9 3411 [3411]   216764 16793 1 [And… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano… 1 [Fijo] 2 [Muj…
#> 10 3411 [3411]   237655 17918 1 [And… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano… 2 [Móvi… 2 [Muj…
#> # ℹ 29,191 more rows
#> # ℹ 205 more variables: EDAD <dbl+lbl>, P0A <dbl+lbl>, ECOPER <dbl+lbl>, ECOESP <dbl+lbl>,
#> #   MEDIO_1 <dbl+lbl>, MEDIO_2 <dbl+lbl>, LEEPRENSA <dbl+lbl>, VETELE <dbl+lbl>,
#> #   OYERADIO <dbl+lbl>, PRENSA <dbl+lbl>, P3AR <dbl+lbl>, TELEVISION <dbl+lbl>,
#> #   P3BR <dbl+lbl>, RADIO <dbl+lbl>, P3CR <dbl+lbl>, GESTIONGOB <dbl+lbl>,
#> #   GESTIONOPO <dbl+lbl>, PROBVOTO <dbl+lbl>, VOTOCORREO <dbl+lbl>, PROBPARTIDOS_1 <dbl+lbl>,
#> #   PROBPARTIDOS_2 <dbl+lbl>, PROBPARTIDOS_3 <dbl+lbl>, PROBPARTIDOS_4 <dbl+lbl>, …
#> # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names