Learn R Programming

pewdata (version 0.1.0)

pew_download: Download datasets from the Pew Research Center

Description

pew_download provides a programmatic and reproducible means to download survey datasets from the Pew Research Center

Usage

pew_download(area = "politics", file_id, name = getOption("pew_name"), org = getOption("pew_org"), phone = getOption("pew_phone"), email = getOption("pew_email"), download_dir = "pew_data", msg = TRUE, unzip = TRUE, delete_zip = TRUE)

Arguments

area
One of the seven research areas of the Pew Research Center (see details).
file_id
The unique identifier (or optionally a vector of these identifiers) for the dataset(s) to be downloaded (see details).
name, org, phone, email
Contact information to submit to Pew Research Center (see details).
download_dir
The directory (relative to your working directory) to which files from the Pew Research Center 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

The Pew Research Center has seven areas of research focus. Pass one of the following strings to the area argument to specify which area generated the datasets you want to download: politics U.S. Politics & Policy (the default) journalism Journalism & Media internet Internet, Science & Tech religion Religion & Public Life hispanic Hispanic Trends global Global Attitudes & Trends socialtrends Social & Demographic Trends

To avoid requiring others to edit your scripts to insert their own contact information, the default is set to fetch this information from the user's .Rprofile. Before running pew_download, then, you should be sure to add these options to your .Rprofile substituting your info for the example below:

options("pew_name" = "Juanita Herrera", "pew_org" = "Upper Midwest University", "pew_phone" = "888-000-0000", "pew_email" = "jherrera@uppermidwest.edu")

Examples

Run this code
## Not run: 
#  pew_download(file_id = c(20059299, 20058139))
# ## End(Not run)

Run the code above in your browser using DataLab