This R package provides easy access to Canadian Election Study (CES) datasets for analysis in R.
You can install the released version of ces from CRAN with:
install.packages("ces")
And the development version from GitHub with:
# install.packages("devtools")
::install_github("laurenceomfoisy/ces") devtools
library(ces)
# Get the 2019 CES data (metadata is preserved by default)
<- get_ces("2019")
ces_2019
# If you need to disable metadata preservation (uncommon)
# ces_2019_minimal <- get_ces("2019", preserve_metadata = FALSE)
# View available datasets
list_ces_datasets()
# Create a codebook for the dataset
<- create_codebook(ces_2019)
codebook
# Examine variable metadata
<- examine_metadata(ces_2019, variable_pattern = "vote")
metadata
# Get subset of variables about voting behavior
<- get_ces_subset("2019", variables = c("vote_choice", "turnout"))
voting_data
# Download the official codebook PDF
download_pdf_codebook("2019")
# Download a single dataset
download_ces_dataset("2019", path = "~/CES_data")
# Download all datasets at once
download_all_ces_datasets(path = "~/CES_data")
For package developers: If you encounter a note about “unable to verify current time” during package check, use this environment setting:
# Disable time verification entirely
Sys.setenv("_R_CHECK_SYSTEM_CLOCK_" = "0")
::check() devtools
This is the CRAN-approved way to eliminate timestamp verification issues.
This package accesses data from the Borealis Data repository, which serves as the official host for the Canadian Election Study datasets. We gratefully acknowledge Borealis Data for maintaining and providing access to these valuable datasets.
The package author is not affiliated with the Canadian Election Study or Borealis Data. Users of this package should properly cite the original Canadian Election Study data in their research publications.
This package was developed with assistance from Claude Sonnet 3.7, an AI assistant by Anthropic. Claude helped with structuring the package, writing documentation, and implementing the core functionality. The collaboration between the human author and AI demonstrates how these tools can be used to create helpful resources for the research community.
This project is licensed under the MIT License - see the LICENSE file for details.