Skip to content

Instantly share code, notes, and snippets.

@SolomonMg
Created March 3, 2015 05:04
Show Gist options
  • Save SolomonMg/4043e15691756071b1ad to your computer and use it in GitHub Desktop.
Save SolomonMg/4043e15691756071b1ad to your computer and use it in GitHub Desktop.
Read in data from Qualtrics to R (adapted from qualtrics R package - http://jason.bryer.org/qualtrics/)
library(RCurl)
getSurveyResults <- function (username,
token, surveyid, truncNames = 20,
Questions = NULL,
Labels = "1",
ExportTags = "1",
LocalTime = "1",
startDate = NULL, endDate = NULL) {
url = paste(
"https://survey.qualtrics.com/WRAPI/ControlPanel/api.php?Request=getLegacyResponseData&User=",
username,
"&Token=", token,
"&SurveyID=", surveyid,
"&Version=2.0",
"&Labels=", Labels,
"&ExportTags=", ExportTags,
"&LocalTime=", LocalTime,
"&Format=CSV",
sep = "")
print(url)
urlcontents <- getURL(url)
urlcontents <- gsub("<ef><bb><bf>", "", urlcontents)
urlcontents <- strsplit(urlcontents, "\\n")[[1]]
dat <- read.csv(text=urlcontents[-1])
dat$X = NULL
dat
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment