Skip to contents

icpsr_download provides a programmatic and reproducible means to download datasets from the Inter-university Consortium for Political and Social Research

Usage

icpsr_download(
  file_id,
  email = getOption("icpsr_email"),
  password = getOption("icpsr_password"),
  reset = FALSE,
  download_dir = "icpsr_data",
  msg = TRUE,
  unzip = TRUE,
  delete_zip = unzip
)

Arguments

file_id

The unique identifier (or optionally a vector of these identifiers) for the dataset(s) to be downloaded (see details).

email, password

Your ICPSR email and password (see details)

reset

If TRUE, you will be asked to re-enter your ICPSR email and password.

download_dir

The directory (relative to your working directory) to which files from the ICPSR will be downloaded.

msg

If TRUE, outputs a message showing which data set is being downloaded.

unzip

If TRUE, the downloaded zip files will be unzipped.

delete_zip

If TRUE, the downloaded zip files will be deleted.

Value

The function returns downloaded files.

Details

icpsr_download provides a programmatic and reproducible means to download datasets from the Inter-university Consortium for Political and Social Research, which requires a user account. Sign up for an account at https://www.icpsr.umich.edu before proceeding.

To avoid requiring others to edit your scripts to insert their own email and password or to force them to do so interactively, the default is set to fetch this information from the user's .Rprofile. Before running icpsr_download, then, you should be sure to add these options to your .Rprofile substituting your info for the example below:

options("icpsr_email" = "[email protected]", "icpsr_password" = "password123!")

If this information is not found a user's .Rprofile, the function will also check in the .Renviron file. Either file may be easily edited via usethis::edit_r_profile() or usethis::edit_r_environ().

Examples

if (FALSE) {
 icpsr_download(file_id = c(3730, 36138),
                download_dir = tempdir()) # remember to specify a directory for your download
}