Skip to contents

Download and import the data of a CIS timeseries.

Usage

read_series(series_code)

Arguments

series_code

A string with the timeseries code.

Value

A data.frame.

Examples

httr::set_config(httr::config(ssl_verifypeer = 0L))
# Use the search_series() function to find a timeserie to import
series <- search_series("presidente preferido")
series
#> # A tibble: 4 × 6
#>      id variable      titulo                    puntos fecha_minima fecha_maxima
#>   <int> <chr>         <chr>                      <int> <chr>        <chr>       
#> 1 15008 A.5.01.02.011 LÍDER PREFERIDO COMO PRE…     14 10-2018      03-2020     
#> 2 15952 A.5.01.02.012 LÍDER PREFERIDO COMO PRE…     16 06-2020      02-2022     
#> 3 16573 B.7.05.05.003 LÍDER POLÍTICO PREFERIDO…      5 10-1987      05-1988     
#> 4 17357 A.5.01.02.013 LÍDER PREFERIDO COMO PRE…     18 03-2022      11-2023     
# Use the value in the id column of the search_series() output
df <- read_series(series_code = series$id[1])
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: There was 1 warning in `mutate()`.
#>  In argument: `pregunta = clean_html_tags(.data$pregunta)`.
#> Caused by warning:
#> ! no DISPLAY variable so Tk is not available
dplyr::glimpse(df)
#> Rows: 168
#> Columns: 16
#> $ id                  <int> 15008, 15008, 15008, 15008, 15008, 15008, 15008, 1…
#> $ codigo_serie        <chr> "A.5.01.02.011", "A.5.01.02.011", "A.5.01.02.011",…
#> $ titulo              <chr> "LÍDER PREFERIDO COMO PRESIDENTE DEL GOBIERNO", "L…
#> $ pregunta            <chr> "Cambiando de tema, de los siguientes líderes polí…
#> $ muestra             <chr> "Nacional (con Ceuta y Melilla) Población española…
#> $ notas               <chr> "", "", "", "", "", "", "", "", "", "", "", "", ""…
#> $ multiVariable       <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, F…
#> $ estudio             <chr> "3226/0", "3226/0", "3226/0", "3226/0", "3226/0", …
#> $ fecha               <chr> "10-2018", "10-2018", "10-2018", "10-2018", "10-20…
#> $ codigo_variable     <chr> "P19R", "P19R", "P19R", "P19R", "P19R", "P19R", "P…
#> $ idEstudio           <chr> "14430", "14430", "14430", "14430", "14430", "1443…
#> $ idPregunta          <chr> "595375", "595375", "595375", "595375", "595375", …
#> $ idVariable          <chr> "826113", "826113", "826113", "826113", "826113", …
#> $ response_categories <chr> "Pablo Casado", "Pablo Iglesias", "Albert Rivera",…
#> $ response_values     <dbl> 10.8, 10.6, 16.9, 25.8, 1.4, NA, NA, NA, 22.0, 2.5…
#> $ X.N.                <dbl> 2973, 2973, 2973, 2973, 2973, 2973, 2973, 2973, 29…