get_ces {ces} | R Documentation |
Get Canadian Election Study Dataset
Description
This function downloads and processes a Canadian Election Study dataset for the specified year.
Usage
get_ces(
year,
format = "tibble",
language = "en",
clean = TRUE,
preserve_metadata = TRUE,
use_cache = TRUE,
verbose = TRUE
)
Arguments
year |
A character string indicating the year of the CES data. Available years include "1965", "1968", "1974-1980", "1984", "1988", "1993", "1997", "2000", "2004", "2006", "2008", "2011", "2015", "2019", "2021". |
format |
A character string indicating the format to return the data in. Default is "tibble". Options include "tibble", "data.frame", or "raw". |
language |
A character string indicating the language of the survey questions. Default is "en" (English). Alternative is "fr" (French). |
clean |
Logical indicating whether to clean the data (recode variables, convert factors, etc.). Default is TRUE. |
preserve_metadata |
Logical indicating whether to prioritize preserving all variable metadata (labels, attributes) over standardization. Default is TRUE. This ensures all original question labels and value labels are maintained. |
use_cache |
Logical indicating whether to use cached data if available. Default is TRUE. |
verbose |
Logical indicating whether to display detailed progress messages during data retrieval and processing. Default is TRUE. |
Value
A tibble or data.frame containing the requested CES data.
Note
Official PDF codebooks for each CES year are available via the
download_pdf_codebook
function, which provides detailed information
about variables, question wording, and methodology.
Examples
# Get the 2019 CES data
ces_2019 <- get_ces("2019")
# Get the 1993 CES data, unprocessed
ces_1993_raw <- get_ces("1993", clean = FALSE)
# Download the official codebook to temporary directory
download_pdf_codebook("2019", path = tempdir())