The Roper Center for Public Opinion Research, in its own words, works “to collect, preserve, and disseminate public opinion data; to serve as a resource to help improve the practice of survey research; and to broaden the understanding of public opinion through the use of survey data in the United States and around the world.” It maintains the largest archive of public opinion data in existence, holding data dating back to the 1930s and from over 100 countries. Researchers taking advantage of these datasets, however, are caught in a bind. The terms and conditions for downloading any Roper Center dataset state that datasets “may not be resold or re-disseminated.”1 But to ensure that one’s work can be reproduced, assessed, and built upon by others, one must provide access to the raw data one employed.
The ropercenter
package cuts this knot by providing
programmatic, reproducible access to specified Roper Center datasets
from within R for registered users
at the Roper Center’s member
institutions.
Please remember that by using Roper Center services, you accept all of the Center’s Terms and Conditions.
The ropercenter
package interacts with the Roper Center
website using the Firefox browser. Get Firefox here.
When used interactively, the roper_download
function
will ask for the login information required by the Roper Center: the
registered user’s affiliation, email, and password. After that
information is input once, it will be entered automatically for any
other download requests made in the same session. To change this contact
information within a session, one may set the argument
reset
to TRUE
when running
roper_download
again, and the function will again request
the required information.
An optional, but highly recommended, setup step is to add the information the Roper Center requires to your .Rprofile as in the following example:
The roper_download
function will then access the
information it needs to pass on to the Roper Center by default. This
means that researchers will not have to expose their info in their R
scripts and that others reproducing their results later—given that they
have registered as users with the Roper Center—will be able to execute
those R scripts without modification. (They will, however, need to enter
their own information either interactively or in their own .Rprofiles, a
detail that should be noted in the reproducibility materials to avoid
confusion.)
The roper_download
function (1) simulates a visit to the
Roper Center’s sign-in page, (2) enters the required information to sign
in, (3) navigates to a specified dataset and downloads the dataset’s
files, and, optionally but by default, (4) converts the dataset’s Stata-
or SPSS-formated files to .Rdata
format.
Datasets are specified using the file_id
argument. The
Roper Center uses a unique ‘archive number’ to identify each of its
datasets; this number is consistently listed alongside the dataset’s
name and under the Study Info tab. For this Fox News
poll on the 2020 U.S. presidential election, for example, the file
id is 31117412:
To reproducibly download this dataset:
roper_download(file_id = "31117412",
download_dir = tempdir()) # remember to specify a directory for your download
Most older surveys also have a Roper ‘historical archive number’ that may also be used as the file id. This CNN/ORC poll on the 2016 U.S. presidential election can be downloaded using either its archive number, 31095595, or its historical archive number, USORCCNN2015-010, as the file id: