You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: materials/sections/survey-workflow.qmd
+34-8Lines changed: 34 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -91,23 +91,22 @@ To get a list of all the surveys in your Qualtrics instance, use the `all_survey
91
91
92
92
```{r, eval = FALSE}
93
93
surveys <- all_surveys()
94
-
kable(surveys) %>%
95
-
kable_styling()
94
+
glimpse(surveys)
96
95
```
97
96
98
97
This function returns a list of surveys, in this case only one, and information about each, including an identifier and it's name. We'll need that identifier later, so let's go ahead and extract it using base R from the data frame.
99
98
100
99
```{r, eval = FALSE}
101
-
i <- which(surveys$name == "Survey for Data Science Training")
102
-
id <- surveys$id[i]
100
+
id <- surveys %>%
101
+
filter(name == "Survey for Data Science Training") %>%
102
+
pull(id)
103
103
```
104
104
105
105
You can retrieve a list of the questions the survey asked using the `survey_questions` function and the survey `id`.
106
106
107
107
```{r, eval = FALSE}
108
108
questions <- survey_questions(id)
109
-
kable(questions) %>%
110
-
kable_styling()
109
+
questions
111
110
```
112
111
113
112
This returns a `data.frame` with one row per question with columns for question id, question name, question text, and whether the question was required. This is helpful to have as a reference for when you are looking at the full survey results.
@@ -116,18 +115,45 @@ To get the full survey results, run `fetch_survey` with the survey id.
116
115
117
116
```{r, eval = FALSE}
118
117
survey_results <- fetch_survey(id)
119
-
glimpse(survey_results)
118
+
survey_results %>% head(1) %>% glimpse
120
119
```
121
120
122
121
The survey results table has tons of information in it, not all of which will be relevant depending on your survey. The table has identifying information for the respondents (eg: `ResponseID`, `IPaddress`, `RecipientEmail`, `RecipientFirstName`, etc), much of which will be empty for this survey since it is anonymous. It also has information about the process of taking the survey, such as the `StartDate`, `EndDate`, `Progress`, and `Duration`. Finally, there are the answers to the questions asked, with columns labeled according to the `qname` column in the questions table (eg: Q1, Q2, Q3). Depending on the type of question, some questions might have multiple columns associated with them. We'll have a look at this more closely in a later example.
123
122
123
+
#### Response metadata
124
+
125
+
As mentioned above, Qualtrics helpfully provides some metadata with each response. Let's use some of this information now. First, you'll noticed a column named `Finished`, containing `TRUE` or `FALSE` values. This indicates whether the respondent fully completed and submitted the survey. In many cases, you will want to filter out unfinished survey responses to avoid analyzing incomplete answers. Let's go ahead and remove those now.
126
+
127
+
```{r, eval = FALSE}
128
+
# Report the frequency of finished vs unfinished responses
Second, you'll noticed columns named `LocationLongitude` and `LocationLatitude`. These give an approximate best-guess location of the respondent based on IP address. This is usually accurate to a city level in the United States, but perhaps only to a country for many international respondents, and can be completely wrong in some cases (e.g., if the respondent is using a VPN). Nevertheless, it can be useful to give at least a rough sense of where your respondents are located. Let's use `leaflet` to draw a quick map of our survey respondents.
136
+
137
+
```{r, eval = FALSE}
138
+
library(leaflet)
139
+
survey_results %>%
140
+
leaflet %>%
141
+
addTiles() %>%
142
+
addMarkers(
143
+
lng = ~ LocationLongitude,
144
+
lat = ~ LocationLatitude,
145
+
popup = ~ Q2
146
+
)
147
+
```
148
+
149
+
124
150
#### Question 2
125
151
126
152
Let's look at the responses to the second question in the survey, "How long have you been programming?" Remember, the first question was the consent question.
127
153
128
154
We'll use the `dplyr` and `tidyr` tools we learned earlier to extract the information. Here are the steps:
0 commit comments