Using ess for R and Stata users

Jorge Cimentada

2017-11-07

Introduction

Using the ess package is fairly easy. There are are two families of functions: ess_* and show_*. They each complement each other and allow the user to almost never have to go to the European Social Survey (ESS) website. The only scenario where you need to enter the ESS website is to validate your email. If you haven’t registered, create an account at http://www.europeansocialsurvey.org/user/new

Once you register visit your email to validate your account and you’re ready to access the data.

Given that some ess functions require your email address, this vignette will use a fake email but everything should work accordingly if you registered with the ESS.

Downloading country specific rounds

To install and load development version of the package use:

if (!require(devtools)) install.packages("devtools")
devtools::install_github("cimentadaj/ess")

library(ess)

Let’s suppose you don’t know which countries or rounds are available for the ESS. Then the show_* family of functions is your friend.

To find out which countries have participated you can use show_countries()

show_countries()
##  [1] "Albania"            "Austria"            "Belgium"           
##  [4] "Bulgaria"           "Croatia"            "Cyprus"            
##  [7] "Czech Republic"     "Denmark"            "Estonia"           
## [10] "Finland"            "France"             "Germany"           
## [13] "Greece"             "Hungary"            "Iceland"           
## [16] "Ireland"            "Israel"             "Italy"             
## [19] "Kosovo"             "Latvia"             "Lithuania"         
## [22] "Luxembourg"         "Netherlands"        "Norway"            
## [25] "Poland"             "Portugal"           "Romania"           
## [28] "Russian Federation" "Slovakia"           "Slovenia"          
## [31] "Spain"              "Sweden"             "Switzerland"       
## [34] "Turkey"             "Ukraine"            "United Kingdom"

This function actually looks up the countries in the ESS website. If new countries enter, this will automatically grab those countries as well. Let’s checkout Turkey. How many rounds has Turkey participated in? We can use show_country_rounds()

tk_rnds <- show_country_rounds("Turkey")
tk_rnds
## [1] 2 4

Note that country names are case sensitive. Use the exact name printed out by show_countries()

Using this information, we can download those specific rounds easily with ess_country.

turkey <-
  ess_country(
    country = "Turkey",
    rounds = c(2, 4),
    your_email = "your_email@random.com"
    )

turkey will now be a list of length(rounds) containing a data frame for each round. ess_country is useful for when you want to download specific rounds, but not all. To download all rounds for a country automatically you can use ess_all_cntrounds.

ess_all_cntrounds("Turkey", "your_email@random.com")

The ess_* family is concerned with downloading the data and thus always returns a list containing data frames. Conversely, the show_* family grabs information from the ESS website and always returns vectors.

Download complete rounds

Similarly, we can use other functions to download rounds. To see which rounds are currently available, use show_rounds.

show_rounds()
## [1] 1 2 3 4 5 6 7 8

Similar to show_countries, show_rounds interactively looks up rounds in the ESS website, so any future rounds will automatically be included.

To download all available rounds, use ess_all_rounds

all_rounds <- ess_all_rounds("your_email@random.com")

Alternatively, use ess_rounds for selected ones.

selected_rounds <- ess_rounds(c(1, 3, 6), "your_email@random.com")

Downloading data for Stata users

All ess_* functions allow the user to save the datasets in a specified folder as .dta files.

For example, to save round two from Turkey in a folder called ./my_folder, we use:

ess_country("Turkey", 2,
            "your_email@random.com",
            only_download = TRUE,
            output_dir = "./myfolder/")

This will save the data to ./myfolder/ESS_Turkey and inside that folder there will be the ESS2 folder that contains the data. If you specify only_download = TRUE, but don’t specify a directory, an error will be raised. All of this applies exactly the same way for ess_rounds.

Note that downloading the data doesn’t run the corresponding .do file on the Stata file. The user should do that on it’s own.

Currently the user can either download the data or use it in R. For example, you can’t download the data into the specified folder and also get the list with the rounds.