Download integrated rounds from the European Social Survey
Source:R/import_rounds.R
import_rounds.Rd
Download integrated rounds from the European Social Survey
Usage
import_rounds(rounds, ess_email = NULL, format = NULL)
import_all_rounds(ess_email = NULL, format = NULL)
download_rounds(
rounds,
ess_email = NULL,
output_dir = getwd(),
format = "stata"
)
Arguments
- rounds
a numeric vector with the rounds to download. See
show_rounds
for all available rounds.- ess_email
a character vector with your email, such as "your_email@email.com". If you haven't registered in the ESS website, create an account at http://www.europeansocialsurvey.org/user/new. A preferred method is to login through
set_email
.- format
the format from which to download the data. By default it is NULL for
import_*
functions and tries to read 'stata', 'spss' and 'sas' in the specific order. This can be useful if some countries don't have a particular format available. Alternatively, the user can specify the format which can either be 'stata', 'spss' or 'sas'. For thedownload_*
functions it is set to 'stata' because the format should be specified before downloading. When usingimport_country
the data will be downloaded and read in theformat
specified. Fordownload_country
, the data is downloaded from the specifiedformat
(only 'spss' and 'stata' supported, see details).- output_dir
a character vector with the output directory in case you want to only download the files using the
download_rounds
. Defaults to your working directory. This will be interpreted as a directory and not a path with a file name.
Value
for import_rounds
if length(rounds)
is 1, it returns a tibble
with the latest version of that round. Otherwise it returns a list of length(rounds)
containing the latest version of each round. For download_rounds
, if
output_dir
is a valid directory, it returns the saved directories invisibly
and saves all the rounds in the chosen format
in output_dir
Details
Use import_rounds
to download specified rounds and import them to R.
import_all_rounds
will download all rounds by default and download_rounds
will download rounds and save them in a specified format
in the supplied
directory.
The format
argument from import_rounds
should not matter to the user
because the data is read into R either way. However, different formats might have
different handling of the encoding of some questions. This option was preserved
so that the user
can switch between formats if any encoding errors are found in the data. For more
details see the discussion here.
For this particular argument in, 'sas' is not supported because the data formats have
changed between ESS waves and separate formats require different functions to be
read. To preserve parsimony and format errors between waves, the user should use
'spss' or 'stata'.
Examples
if (FALSE) { # \dontrun{
set_email("your_email@email.com")
# Get first three rounds
three_rounds <- import_rounds(1:3)
temp_dir <- tempdir()
# Only download the files to output_dir, this will return nothing.
download_rounds(
rounds = 1:3,
output_dir = temp_dir,
)
# By default, download_rounds saves a 'stata' file. You can
# also download 'spss' and 'sas' files.
download_rounds(
rounds = 1:3,
output_dir = temp_dir,
format = 'spss'
)
# If rounds are repeated, will download only unique ones
two_rounds <- import_rounds(c(1, 1))
# If email is not registered at ESS website, error will arise
two_rounds <- import_rounds(c(1, 2), "wrong_email@email.com")
# Error in authenticate(ess_email) :
# The email address you provided is not associated with any registered user.
# Create an account at https://www.europeansocialsurvey.org/user/new
# If selected rounds don't exist, error will arise
two_rounds <- import_rounds(c(1, 22))
# Error in round_url(rounds) :
# ESS round 22 is not a available. Check show_rounds()
} # }