Package 'CEOdata'

Title: Datasets of the CEO (Centre d'Estudis d'Opinio) for Opinion Polls in Catalonia
Description: Easy and convenient access to the datasets of the "Centre d'Estudis d'Opinio", the Catalan institution for polling and public opinion. The package retrieves microdata directly from the open data platform of the Generalitat de Catalunya and returns it in a tidy format.
Authors: Xavier Fernández-i-Marín [aut] (ORCID: <https://orcid.org/0000-0002-9522-8870>), Joel Ardiaca [aut, cre] (ORCID: <https://orcid.org/0009-0004-4937-8941>)
Maintainer: Joel Ardiaca <[email protected]>
License: GPL-3
Version: 1.4.0
Built: 2026-05-29 09:29:35 UTC
Source: https://github.com/ceopinio/ceodata

Help Index


Import metadata for accumulated microdata series (Dades Obertes)

Description

Returns the catalogue of "microdades acumulades" series published in Dades Obertes (Socrata). Each row corresponds to a series, identified by codi_serie (e.g. "BOP_presencial").

Usage

CEOaccumulated_meta(series = NULL, active_only = FALSE)

Arguments

series

Optional character vector. If provided, filters results to those codi_serie.

active_only

Logical. If TRUE, keeps only series marked as active (best-effort; depends on estat field).

Value

A tibble with the metadata of the accumulated microdata series.

Examples

## Not run: 
m <- CEOaccumulated_meta()
unique(m$codi_serie)

CEOaccumulated_meta(series = "BOP_presencial")

## End(Not run)

Import datasets / microdata from the Centre d'Estudis d'Opinio

Description

Easy and convenient access to datasets / microdata from the "Centre d'Estudis d'Opinio". The function can return either: (1) an accumulated microdata series (identified by series), or (2) a single study microdata dataset (identified by reo).

Usage

CEOdata(series = "BOP_presencial", reo = NA, raw = FALSE)

Arguments

series

Character scalar identifying the accumulated series to download. Ignored when reo is provided.

reo

Single REO identifier of a study to download. Can be character, numeric, or factor-like, and is normalized internally.

raw

Logical. If FALSE (default), converts SPSS labelled vectors into factors. If TRUE, returns raw haven-labelled vectors.

Details

Accumulated series are obtained from the Dades Obertes catalogue and are usually identified by codi_serie (e.g. "BOP_presencial").

Value

A tibble with individuals' responses to the requested dataset.

Examples

## Not run: 
# Default: accumulated microdata series
d <- CEOdata()

# Load another accumulated series by code
d_tel <- CEOdata(series = "BOP_telefonica")

# Load a single study by REO
d1145 <- CEOdata(reo = "1145")

## End(Not run)

Import metadata from the "Centre d'Estudis d'Opinio"

Description

Easy and convenient access to the metadata of the "Centre d'Estudis d'Opinio", the Catalan institution for polling and public opinion.

Usage

CEOmeta(
  reo = NULL,
  search = NULL,
  date_start = NA,
  date_end = NA,
  browse = FALSE,
  browse_translate = NULL,
  browse_force = FALSE
)

Arguments

reo

Character vector with one or more REO identifiers. When not NULL it has precedence over search, date_start, and date_end.

search

Character vector with keywords to look for in metadata text fields. Each element is interpreted as one search expression; multiple elements are combined with OR. Matching is case-insensitive.

date_start

Optional start date ("YYYY-MM-DD" or Date) for ⁠Data d'alta al REO⁠.

date_end

Optional end date ("YYYY-MM-DD" or Date) for ⁠Data d'alta al REO⁠.

browse

Logical value. If TRUE, open matching metadata URLs in the browser (up to 10 entries unless browse_force = TRUE).

browse_translate

Optional language code when browse = TRUE: 'oc' (Apertium), or Google-Translate target among 'de', 'en', 'eu', 'gl', 'sp'/'es'.

browse_force

Logical value. If TRUE, bypasses the safety limit of opening at most 10 URLs.

Value

A tibble with the metadata of surveys produced by the CEO.

Examples

## Not run: 
# Retrieve metadata of all surveys:
meta <- CEOmeta()
dim(meta)

# Search for specific terms:
CEOmeta(search = "internet")

# "Medi" AND "Ambient"
CEOmeta(search = "Medi ambient")

# ("Medi" AND "Ambient") OR "Municipi"
CEOmeta(search = c("Medi ambient", "Municipi"))

# Search for entries starting in 2020
CEOmeta(date_start = "2020-01-01")

# Get a specific REO and open its description in browser
CEOmeta(reo = "746", browse = TRUE)

## End(Not run)

Search for keywords in the labels of variables and responses of the survey data

Description

Easy and convenient access to the metadata of the "Centre d'Estudis d'Opinio", the Catalan institution for polling and public opinion. It allows to search for specific terms to obtain the details of the datasets available

Usage

CEOsearch(d, keyword = NULL, where = "variables", translate = FALSE)

Arguments

d

Microdata retrieved from the CEO using the CEOdata() function. It is a data frame with variable labels.

keyword

The character string defining the word / concept to look for within the microdata.

where

A character vector specifying if the function should look amongst variable labels ("variables", default), or amongst value labels ("values").

translate

Logical. When TRUE, it opens a browser with an automatic translation to English of the variable names and labels using Google Translate. Given the specificity of the terms, only the English translation is provided. Defaults to FALSE.

Value

A tibble with the set of variables that match the keyword ("Variable"). If the variables are requested, the second variable is their labels ("Label"), and if the values are required the second on is the value labels ("Value").

Examples

## Not run: 
# Retrieve a dataset to use the function
d <- CEOdata()

# Get the whole set of variable labels
CEOsearch(d)

# Get the whole set of value labels
CEOsearch(d, where = "values")

# Search for specific variable names and variable labels with the string "edat" (age).
CEOsearch(d, keyword = "edat")

# Search for specific variable names and variable labels with the string "edat" (age),
# and translate the results to English.
CEOsearch(d, keyword = "edat", translate = TRUE)

# now for the combination of "valoracio" OR "covid" OR "govern".
CEOsearch(d, keyword = c("valoració", "covid",  "govern"))

## End(Not run)