qsurvey is a toolkit for working with the Qualtrics survey platform and its data in R. It focuses on testing and review of surveys before fielding, and analysis of responses afterward.
Install the latest version from GitHub:
# install.packages("devtools") devtools::install_github("jamesdunham/qsurvey")
A Qualtrics API key is needed to communicate with the survey platform. Set the environment variable
QUALTRICS_KEY to your key value. You can do this during R startup (recommended), interactively with
Sys.setenv(), or through
Qualtrics assigns each survey a unique id. You can search by survey name for an id using
surveys() to see the ids and other metadata for all surveys, in a table similar to the Qualtrics Control Panel overview.
Pass a survey’s id to
responses() to retrieve responses. This is equivalent to using the “Export Data” tool in the “Data and Analysis” view of the Control Panel and then reading the resulting file into R.
r <- responses(id = "SV_0CGgkDZJaUvxnGl", verbose = FALSE)
To retrieve a survey’s design use
design(). This returns a
qualtrics_design object that many other qsurvey functions can operate on.
d <- design(id = "SV_0CGgkDZJaUvxnGl") print(d) #> # A qualtrics_design: #> name Student Feedback #> id SV_0CGgkDZJaUvxnGl #> created 2016-11-24 #> modified 2016-11-24 #> responses 0 (closed) #> questions 26 #> blocks 3
For example, use
questions() to see the text and other attributes of each survey question.
svy_q <- questions(design_object = d) svy_q[1:2, ] #> question_order question_id export_name #> 1: 1 QID132224516 Q1 #> 2: 2 QID132224536 Q3 #> question_text #> 1: Overall, how satisfied or dissatisfied were you with this class? #> 2: How interesting was this class?