{"id":19079803,"url":"https://github.com/hmeleiro/opencis","last_synced_at":"2025-07-31T18:03:21.541Z","repository":{"id":207605461,"uuid":"719644950","full_name":"hmeleiro/opencis","owner":"hmeleiro","description":"R package to import data from spanish Sociological Research Center (CIS)","archived":false,"fork":false,"pushed_at":"2023-12-12T09:22:11.000Z","size":4345,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-02T19:21:25.843Z","etag":null,"topics":["abiertos","api","centro","cis","data","datos","estudios","open","r","sociologicos"],"latest_commit_sha":null,"homepage":"https://hmeleiro.github.io/opencis/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hmeleiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-16T15:51:31.000Z","updated_at":"2024-09-05T11:02:43.000Z","dependencies_parsed_at":"2023-12-12T10:30:38.835Z","dependency_job_id":"13646cde-d4aa-4f81-b5af-d4d5fb29c058","html_url":"https://github.com/hmeleiro/opencis","commit_stats":null,"previous_names":["hmeleiro/opencis"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmeleiro%2Fopencis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmeleiro%2Fopencis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmeleiro%2Fopencis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmeleiro%2Fopencis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hmeleiro","download_url":"https://codeload.github.com/hmeleiro/opencis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240131760,"owners_count":19752727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abiertos","api","centro","cis","data","datos","estudios","open","r","sociologicos"],"created_at":"2024-11-09T02:16:03.890Z","updated_at":"2025-02-22T05:41:32.244Z","avatar_url":"https://github.com/hmeleiro.png","language":"R","funding_links":[],"categories":["Datos Abiertos y Estadísticas"],"sub_categories":["Región de Murcia"],"readme":"# opencis\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/opencis)](https://CRAN.R-project.org/package=opencis)\n[![R-CMD-check](https://github.com/hmeleiro/opencis/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/hmeleiro/opencis/actions/workflows/R-CMD-check.yaml)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\u003c!-- badges: end --\u003e\n\nSearch 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.\n\n## Installation\n\nYou can install `opencis` from Github using the `devtools` package:\n\n``` r\ndevtools::install_github(\"hmeleiro/opencis\")\n```\n\n\n## Usage\n\nThe package includes three group of functions. \n\nThe first group is used to search for surveys, survey questions and timeseries. \n\n``` r\n# Search for survey studies\nsearch_studies(search_terms = \"preelectoral\", \n               since_date = \"01-01-2020\", \n               until_date = \"17-11-2023\")\n#\u003e # A tibble: 456 × 4\n#\u003e       id codigo titulo                                             fecha     \n#\u003e    \u003cint\u003e \u003cchr\u003e  \u003cchr\u003e                                              \u003cdate\u003e    \n#\u003e  1 14724 3411   PREELECTORAL ELECCIONES GENERALES 2023             2023-06-08\n#\u003e  2 14718 3402   PREELECTORAL ELECCIONES MUNICIPALES Y AUTONÓMICAS… 2023-04-10\n#\u003e  3 14629 3365   PREELECTORAL ELECCIONES AUTONÓMICAS 2022. COMUNID… 2022-05-17\n#\u003e  4 14605 3348   PREELECTORAL ELECCIONES AUTONÓMICAS 2022. COMUNID… 2022-01-07\n#\u003e  5 14558 3317   PREELECTORAL ELECCIONES AUTONÓMICAS 2021. COMUNID… 2021-03-19\n#\u003e  6 14541 3306   PREELECTORAL DE CATALUÑA. ELECCIONES AUTONÓMICAS … 2021-01-02\n#\u003e  7 14513 3286   PREELECTORAL DEL PAÍS VASCO. ELECCIONES AUTONÓMIC… 2020-06-10\n#\u003e  8 14514 3287   PREELECTORAL DE GALICIA. ELECCIONES AUTONÓMICAS J… 2020-06-10\n#\u003e  9 14491 3275   PREELECTORAL DEL PAÍS VASCO. ELECCIONES AUTONÓMIC… 2020-02-17\n#\u003e 10 14492 3276   PREELECTORAL DE GALICIA. ELECCIONES AUTONÓMICAS A… 2020-02-17\n#\u003e # ℹ 446 more rows\n#\u003e # ℹ Use `print(n = ...)` to see more rows\n\n\n# Search for survey questions\nsearch_questions(search_terms = \"feminismo\")\n#\u003e # A tibble: 6 × 7\n#\u003e       id id_estudio codigo    titulo fecha_estudio titulo_cuestionario series\n#\u003e    \u003cint\u003e      \u003cint\u003e \u003cchr\u003e     \u003cchr\u003e  \u003cdate\u003e        \u003cchr\u003e               \u003clist\u003e\n#\u003e 1 491141      10002 2828/0 0… Rasgo… 2010-01-09    BARÓMETRO DE ENERO… \u003cNULL\u003e\n#\u003e 2 485492       1384 2401/0 0… Rasgo… 2000-12-09    25 AÑOS DESPUÉS     \u003cNULL\u003e\n#\u003e 3 493678       1202 2212/0 0… Senti… 1996-04-13    BARÓMETRO DE ABRIL… \u003cNULL\u003e\n#\u003e 4 479219       1144 2154/0 0… Rasgo… 1995-04-04    CULTURA POLÍTICA (… \u003cNULL\u003e\n#\u003e 5 449988       1008 2016/0 0… Rasgo… 1992-07-09    BARÓMETRO DE JULIO… \u003cNULL\u003e\n#\u003e 6 452793        985 1993/0 0… Senti… 1992-02-27    BARÓMETRO DE FEBRE… \u003cNULL\u003e\n\n# Search for timeseries\nsearch_series(search_terms = \"situación económica\")\n#\u003e # A tibble: 85 × 6\n#\u003e       id variable      titulo                     puntos fecha_minima fecha_maxima\n#\u003e    \u003cint\u003e \u003cchr\u003e         \u003cchr\u003e                       \u003cint\u003e \u003cchr\u003e        \u003cchr\u003e       \n#\u003e  1  2092 K.1.02.02.002 VALORACIÓN RETROSPECTIVA …    223 10-1978      03-2020     \n#\u003e  2  2295 K.1.02.01.003 VALORACIÓN DE LA SITUACIÓ…     21 05-1986      10-2019     \n#\u003e  3  2460 K.1.03.02.001 VALORACIÓN PROSPECTIVA DE…    106 04-1995      03-2020     \n#\u003e  4  2462 K.1.03.02.003 VALORACIÓN PROSPECTIVA DE…     10 12-1986      02-1999     \n#\u003e  5  2463 K.1.03.02.004 VALORACIÓN RETROSPECTIVA …     15 04-1992      01-2011     \n#\u003e  6  2464 K.1.03.01.001 VALORACIÓN DE LA SITUACIÓ…    118 04-1992      03-2020     \n#\u003e  7  2467 K.1.03.02.005 VALORACIÓN RETROSPECTIVA …     11 02-1992      02-1999     \n#\u003e  8  2469 K.1.03.02.008 VALORACIÓN PROSPECTIVA DE…      6 05-2001      11-2017     \n#\u003e  9  3075 K.1.02.01.001 VALORACIÓN DE LA SITUACIÓ…    364 06-1979      03-2020     \n#\u003e 10  3076 K.1.02.02.001 VALORACIÓN PROSPECTIVA DE…    344 10-1978      03-2020     \n#\u003e # ℹ 75 more rows\n#\u003e # ℹ Use `print(n = ...)` to see more rows\n```\n\nThe second group of functions retrieves the valid category codes to narrow search queries. [Read the documentation](https://hmeleiro.github.io/opencis/reference/index.html#retrieve-categories) to understand how to use the category codes in the search functions.\n\n``` r\nget_study_categories()\n#\u003e # A tibble: 213 × 4\n#\u003e       id conteo codigo      titulo                              \n#\u003e    \u003cint\u003e  \u003cint\u003e \u003cchr\u003e       \u003cchr\u003e                               \n#\u003e  1     1   1356 001         POLÍTICA                            \n#\u003e  2     1     24 001_000     Política                            \n#\u003e  3     2    222 001_001     Estado, Constitución e instituciones\n#\u003e  4     2     94 001_001_000 Estado, constitución e instituciones\n#\u003e  5   210     56 001_001_001 Constitución                        \n#\u003e  6     4     29 001_001_002 Fuerzas Armadas y defensa           \n#\u003e  7     3     66 001_001_003 Gobierno                            \n#\u003e  8   551     22 001_001_004 Monarquía                           \n#\u003e  9     5    197 001_002     Administración y servicios públicos \n#\u003e 10     6    301 001_003     Cultura política                    \n#\u003e # ℹ 203 more rows\n#\u003e # ℹ Use `print(n = ...)` to see more rows\n\nget_question_categories()\n#\u003e # A tibble: 5,257 × 4\n#\u003e       id conteo codigo              titulo                  \n#\u003e    \u003cint\u003e  \u003cint\u003e \u003cchr\u003e               \u003cchr\u003e                   \n#\u003e  1  1637 154084 003                 DESCRIPTORES            \n#\u003e  2     1   1699 003_001             Ciencia                 \n#\u003e  3     1     92 003_001_000         Ciencia                 \n#\u003e  4     2     16 003_001_001         Ciencia espacial        \n#\u003e  5     3    117 003_001_002         Desarrollo científico   \n#\u003e  6     4    599 003_001_003         Investigación científica\n#\u003e  7     4    122 003_001_003_000     Investigación científica\n#\u003e  8     5    402 003_001_003_001     Métodos de investigación\n#\u003e  9     6    402 003_001_003_001_001 Encuestas               \n#\u003e 10     7     23 003_001_003_001_002 Trabajo de campo        \n#\u003e # ℹ 5,247 more rows\n#\u003e # ℹ Use `print(n = ...)` to see more rows\n\nget_series_category()\n#\u003e # A tibble: 4,433 × 6\n#\u003e     dmid conteo dmvariable    dmtitulo                        dmprquestion dmindex\n#\u003e    \u003cint\u003e  \u003cint\u003e \u003cchr\u003e         \u003cchr\u003e                           \u003cchr\u003e        \u003cchr\u003e  \n#\u003e  1   235   1190 A             ESTADO, SISTEMA POLÍTICO        \"\"           001    \n#\u003e  2   221     92 A.1           CONSTITUCIÓN E INSTITUCIONES    \"\"           001_001\n#\u003e  3   222     24 A.1.01        CONSTITUCIÓN                    \"\"           001_00…\n#\u003e  4   223      6 A.1.01.01     CONOCIMIENTO DE LA CONSTITUCIÓN \"\"           001_00…\n#\u003e  5  2535      1 A.1.01.01.001 GRADO DE CONOCIMIENTO DE LA CO… \"\u003cp style=\\… 001_00…\n#\u003e  6  2977      1 A.1.01.01.002 GRADO DE CONOCIMIENTO DE LA CO… \"\u003cp style=\\… 001_00…\n#\u003e  7  2978      1 A.1.01.01.004 GRADO DE ESFUERZO DE LOS GOBIE… \"\u003cp style=\\… 001_00…\n#\u003e  8 16109      1 A.1.01.01.009 ACUERDO CON DISTINTOS MEDIOS D… \"\u003cp style=\\… 001_00…\n#\u003e  9 16110      1 A.1.01.01.010 ACUERDO CON DISTINTOS MEDIOS D… \"\u003cp style=\\… 001_00…\n#\u003e 10 16112      1 A.1.01.01.011 ACUERDO CON DISTINTOS MEDIOS D… \"\u003cp style=\\… 001_00…\n#\u003e # ℹ 4,423 more rows\n#\u003e # ℹ Use `print(n = ...)` to see more rows\n\n```\n\n\nThe third group of functions are used to import the data directly into R. \n\n``` r\n# Read a survey study\ndf \u003c- read_cis(\"3411\")\n#\u003e probando la URL 'https://www.cis.es/documents/d/cis/MD3411'\n#\u003e Content type 'application/zip' length 14194752 bytes (13.5 MB)\n#\u003e downloaded 13.5 MB\nprint(df)\n#\u003e Invalid date string (length=9): 11 042 23\n#\u003e # A tibble: 29,201 × 216\n#\u003e    ESTUDIO     REGISTRO  CUES CCAA         PROV    MUN     CAPITAL TAMUNI  ENTREV \n#\u003e    \u003cdbl+lbl\u003e      \u003cdbl\u003e \u003cdbl\u003e \u003cdbl+lbl\u003e    \u003cdbl+l\u003e \u003cdbl+l\u003e \u003cdbl+l\u003e \u003cdbl+l\u003e \u003cdbl+l\u003e\n#\u003e  1 3411 [3411]   492777 29043 1 [Andalucí… 4 [Alm… 0 [Mun… 3 [Otr… 1 [Men… 0 [Ano…\n#\u003e  2 3411 [3411]    70655  5848 1 [Andalucí… 4 [Alm… 0 [Mun… 3 [Otr… 1 [Men… 0 [Ano…\n#\u003e  3 3411 [3411]    46423  3893 1 [Andalucí… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano…\n#\u003e  4 3411 [3411]   103464  8711 1 [Andalucí… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano…\n#\u003e  5 3411 [3411]   112810  9517 1 [Andalucí… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano…\n#\u003e  6 3411 [3411]   126567 10736 1 [Andalucí… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano…\n#\u003e  7 3411 [3411]   137692 11573 1 [Andalucí… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano…\n#\u003e  8 3411 [3411]   182178 14839 1 [Andalucí… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano…\n#\u003e  9 3411 [3411]   216764 16793 1 [Andalucí… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano…\n#\u003e 10 3411 [3411]   237655 17918 1 [Andalucí… 4 [Alm… 0 [Mun… 3 [Otr… 3 [10.… 0 [Ano…\n#\u003e # ℹ 29,191 more rows\n#\u003e # ℹ 207 more variables: TIPO_TEL \u003cdbl+lbl\u003e, SEXO \u003cdbl+lbl\u003e, EDAD \u003cdbl+lbl\u003e,\n#\u003e #   P0A \u003cdbl+lbl\u003e, ECOPER \u003cdbl+lbl\u003e, ECOESP \u003cdbl+lbl\u003e, MEDIO_1 \u003cdbl+lbl\u003e,\n#\u003e #   MEDIO_2 \u003cdbl+lbl\u003e, LEEPRENSA \u003cdbl+lbl\u003e, VETELE \u003cdbl+lbl\u003e, OYERADIO \u003cdbl+lbl\u003e,\n#\u003e #   PRENSA \u003cdbl+lbl\u003e, P3AR \u003cdbl+lbl\u003e, TELEVISION \u003cdbl+lbl\u003e, P3BR \u003cdbl+lbl\u003e,\n#\u003e #   RADIO \u003cdbl+lbl\u003e, P3CR \u003cdbl+lbl\u003e, GESTIONGOB \u003cdbl+lbl\u003e, GESTIONOPO \u003cdbl+lbl\u003e,\n#\u003e #   PROBVOTO \u003cdbl+lbl\u003e, VOTOCORREO \u003cdbl+lbl\u003e, PROBPARTIDOS_1 \u003cdbl+lbl\u003e, …\n#\u003e # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names\n\n# Read a timeseries\ndf_series \u003c- read_series(\"2092\")\nprint(df_series)\n#\u003e # A tibble: 1,115 × 16\n#\u003e       id codigo_serie  titulo   pregunta muestra notas multiVariable estudio fecha\n#\u003e    \u003cint\u003e \u003cchr\u003e         \u003cchr\u003e    \u003cchr\u003e    \u003cchr\u003e   \u003cchr\u003e \u003clgl\u003e         \u003cchr\u003e   \u003cchr\u003e\n#\u003e  1  2092 K.1.02.02.002 VALORAC… \"\u003cp sty… Nacion… \"\"    FALSE         1169/1  10-1…\n#\u003e  2  2092 K.1.02.02.002 VALORAC… \"\u003cp sty… Nacion… \"\"    FALSE         1169/1  10-1…\n#\u003e  3  2092 K.1.02.02.002 VALORAC… \"\u003cp sty… Nacion… \"\"    FALSE         1169/1  10-1…\n#\u003e  4  2092 K.1.02.02.002 VALORAC… \"\u003cp sty… Nacion… \"\"    FALSE         1169/1  10-1…\n#\u003e  5  2092 K.1.02.02.002 VALORAC… \"\u003cp sty… Nacion… \"\"    FALSE         1169/1  10-1…\n#\u003e  6  2092 K.1.02.02.002 VALORAC… \"\u003cp sty… Nacion… \"\"    FALSE         1189/0  06-1…\n#\u003e  7  2092 K.1.02.02.002 VALORAC… \"\u003cp sty… Nacion… \"\"    FALSE         1189/0  06-1…\n#\u003e  8  2092 K.1.02.02.002 VALORAC… \"\u003cp sty… Nacion… \"\"    FALSE         1189/0  06-1…\n#\u003e  9  2092 K.1.02.02.002 VALORAC… \"\u003cp sty… Nacion… \"\"    FALSE         1189/0  06-1…\n#\u003e 10  2092 K.1.02.02.002 VALORAC… \"\u003cp sty… Nacion… \"\"    FALSE         1189/0  06-1…\n#\u003e # ℹ 1,105 more rows\n#\u003e # ℹ 7 more variables: codigo_variable \u003cchr\u003e, idEstudio \u003cchr\u003e, idPregunta \u003cchr\u003e,\n#\u003e #   idVariable \u003cchr\u003e, response_categories \u003cchr\u003e, response_values \u003cdbl\u003e,\n#\u003e #   X.N. \u003cdbl\u003e\n#\u003e # ℹ Use `print(n = ...)` to see more rows\n```\n\n\n## SSL certificate error on Ubuntu\nDue to an issue with the SSL certificate of CIS website the following error may be thrown on Ubuntu systems:\n```\nSSL peer certificate or SSH remote key was not OK: [www.cis.es] SSL certificate problem: unable to get local issuer certificate\n```\n\nTo solve this problem the user must disable the SSL peer verification option. To do so the following command must be run once in each session:\n\n```\nhttr::set_config(httr::config(ssl_verifypeer = 0L))\n```\n\nI understand that disabling the SSL peer verification option is not ideal as it may be a security risk, but this is not an `opencis` issue, it's a problem on the CIS end side. It has to do with the security certificate presented by the CIS website not been issued by a trusted certificate authority.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmeleiro%2Fopencis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhmeleiro%2Fopencis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmeleiro%2Fopencis/lists"}