qualtRics (version 1.0)

getSurvey: Export a survey and download into R

Description

Export a qualtrics survey you own and import the survey directly into R. NOTE: If you keep getting errors try to use your institution's base URL. See https://api.qualtrics.com/docs/root-url.

Usage

getSurvey(surveyID, root_url, useLabels = TRUE,
  convertStandardColumns = TRUE, lastResponseId = NULL, startDate = NULL,
  endDate = NULL, save_dir = NULL, force_request = FALSE,
  verbose = FALSE)

Arguments

surveyID

Unique ID for the survey you want to download. Returned as 'id' by the getSurveys function.

root_url

Base url for your institution (see https://api.qualtrics.com/docs/csv. You need to supply this url. Your query will NOT work without it.).

useLabels

TRUE to export survey responses as Choice Text or FALSE to export survey responses as values

convertStandardColumns

logical, defaults to TRUE. If TRUE, then the function will convert general data columns (first name, last name, lat, lon, ip address, startdate, enddate etc.) to their proper format.

lastResponseId

Export all responses received after the specified response

startDate

Date range filter to only exports responses recorded after the specified date. Accepts dates as character strings in format "YYYY-MM-DD"

endDate

Date range filter to only exports responses recorded before the specified date. Accepts dates as character strings in format "YYYY-MM-DD"

save_dir

Directory where survey results will be stored. Defaults to a temporary directory which is cleaned when your R session is terminated. This parameter is useful if you'd like to store survey results. The downloaded survey will be stored as an RDS file (see readRDS).

force_request

getSurvey() saves each survey in a temporary directory so that it can quickly be retrieved later. If force_request is TRUE, getSurvey() always downloads the survey from the API instead of loading it from the temporary directory.

verbose

Print verbose messages to the R console? Defaults to FALSE

See Also

See https://api.qualtrics.com/docs/csv for documentation on the Qualtrics API.

Examples

Run this code

registerApiKey("<YOUR-QUALTRICS-API-KEY>")
surveys <- getSurveys("https://leidenuniv.eu.qualtrics.com")
                      # URL is for my own institution.
                      # Substitute with your own institution's url
mysurvey <- getSurvey(surveys$id[6],
                      save_dir = tempdir(),
                      "https://leidenuniv.eu.qualtrics.com",
                      verbose=TRUE)

Run the code above in your browser using DataLab