The GESIS Data Catalogue offers a repository of approximately 5,000 datasets.
library(gesis)
We start by listing all available groups of studies:
groups <- get_study_groups() head(groups, 10)
We see that the Eurobarometer has study group number 0008. Let's looks at all available Eurobarometer waves:
eurobars <- get_datasets("0008") head(eurobars)
We would now like to download the first three studies. We first need to log in
to the Gesis website and then pass the DOIs (unique data set identifiers) to
download_dataset
:
# username and password stored as environment # variables "GESIS_USER" and "GESIS_PASS" gesis_session <- login()
if(!dir.exists("downloads")) dir.create("downloads")
download_dataset(s = gesis_session, doi = eurobars$doi[1:3], path = "downloads", filetype = ".dta")
files <- list.files("downloads", full.names = TRUE)
We can also download the codebooks for the same studies:
download_codebook(eurobars$doi[1:3], path = "downloads")
Using the haven
package we can now read the data sets:
# library(haven) df <- read_dta(files[1]) dim(df)
unlink("downloads", recursive = TRUE)
Disclaimer: the gesis
package is neither affiliated with, nor endorsed by, the
Leibniz Institute for the Social Sciences. I have been unable to find any
indication that programmatic access to the website is disallowed under its terms
of use (indeed, its
guidelines appear to
encourage it). That said, I would discourage users from using the gesis
package to put undue pressure on their servers by initiating unnecessary (or
unnecessarily large) batch downloads.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.