-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.Rmd
executable file
·574 lines (413 loc) · 12.7 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
---
title: "Using formr to create R-powered surveys with individualized feedback"
author: "John Paul Helveston"
output:
xaringan::moon_reader:
css: ["default", "css/lexis.css", "css/lexis-fonts.css"]
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
slideNumberFormat: ""
ratio: "16:9"
seal: false
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
warning = FALSE,
message = FALSE,
comment = "#>",
fig.path = "figs/",
fig.retina = 3 # Better figure resolution
)
library(knitr)
library(fontawesome)
```
```{r xaringan-tile-view, echo=FALSE}
# Enables the ability to show all slides in a tile overview by pressing "o"
# devtools::install_github("gadenbuie/xaringanExtra")
xaringanExtra::use_tile_view()
```
layout: true
<!-- this adds the link footer to all slides, depends on my-footer class in css-->
<div class="footer-small">
<span>
https://github.com/jhelvy/surveys-with-formr
</span>
</div>
---
name: title-slide
class: inverse, center, middle
background-image: url(images/blackboard.jpg)
# Using {formr} to create `r fa("r-project", fill = "white")` powered surveys<br>with individualized feedback
```{r child="faces.Rmd"}
```
.large[by John Paul Helveston]
Jan. 21, 2021
???
Hi I'm John Helveston, and thanks for tuning in to my lightning talk on how to make R-powered surveys with {formr}
---
class: center, middle
.leftcol[.noborder[
<br><br><br>
<center>
<img src="images/surveymonkey.svg" width=600>
</center>
]]
.rightcol[.noborder[
<center>
<img src="images/google-forms-logo.png" width=500>
</center>
]]
???
If you're someone who has ever had to make a survey, chances are you've probably used something like Survey Monkey or Google Forms.
And these platforms work great for simple surveys.
---
class: center, middle
.noborder[
<center>
<img src="images/simple-complex.svg" width=900>
</center>
]
???
But what if you needed your survey to be a little more complex than what these platforms offer?
---
class: center, middle, inverse
```{r child="formr-logo.Rmd"}
```
???
Well, thankfully some really clever people made formr, which uses R and RMarkdown code to create rich, complex surveys.
---
class: center, middle
.leftcol[.circle[
<center>
<img src="images/ruben.jpg" width=350>
</center>
]
### Ruben C. Arslan
# [`r fa("github")`](https://github.com/rubenarslan) [`r fa("twitter")`](https://twitter.com/rubenarslan)
]
.rightcol[.circle[
<center>
<img src="images/cyril.jpg" width=350>
</center>
]
### Cyril S. Tata
# [`r fa("github")`](https://github.com/cyriltata) [`r fa("twitter")`](https://twitter.com/cyriltata)
]
???
And just to be clear, I'm not one of those clever people.
Formr was developed by Ruben Arslan and Cyril Tata.
---
class: center, middle, inverse
.leftcol[
# .font200[I `r fa("heart", fill = "red")`]
```{r child="formr-logo.Rmd"}
```
]
.rightcol[.circle[
<center>
<img src="images/helveston.jpg" width=350>
</center>
# [`r fa("github", fill = "white")`](https://github.com/jhelvy) [`r fa("twitter", fill = "white")`](https://twitter.com/JohnHelveston)
]]
???
I'm just a formr super fan, and I made this talk to share it with the rest of the R community and to demonstrate some of the cool things you can do with it.
---
class: center, middle, inverse
```{r child="formr-logo.Rmd"}
```
# .font200[`r fa("question", fill = "white")`]
???
So what can formr do?
---
class: middle, center, inverse
<style>
.columnnarrow {
float: left;
width: 20%;
padding: 5px;
}
</style>
.leftcol[.noborder[
<br><br><br><br><img src="images/surveymonkey.svg">
]]
.columnnarrow[<br><br>
# .font200[`r fa("plus", fill = "white")`]
]
.rightcol30[
<center>
<img src="https://raw.githubusercontent.com/rstudio/hex-stickers/master/PNG/rmarkdown.png">
</center>
]
???
Well, I kind of think it like Survey Monkey plus RMarkdown.
You can use it create simple surveys, but you can also use R code to generate a much richer set of features.
---
class: middle, center
<center>
<img src="images/htmlwidgets.gif" width=700>
</center>
https://formr.org/interactive_charts
???
For example, you could create interactive charts that survey respondents could experience while taking the survey.
---
class: middle, center
.noborder[
<center>
<img src="images/feedback.png" width=820>
</center>
]
.left[.font70[Fig. 3 from Arslan, R.C., Walther, M.P. & Tata, C.S. [formr: A study framework allowing for automated feedback generation and complex longitudinal experience-sampling studies using R](https://link.springer.com/article/10.3758/s13428-019-01236-y). Behav Res 52, 376–387 (2020).]]
???
Or you could use R code to generate dynamic feedback.
For example, images like this were generated with ggplot code for each respondent in a longitudinal study, showing them their risk preferences for different activities based on their answers to previous questions.
---
class: middle, center, inverse
# .font200[how]
```{r child="formr-logo.Rmd"}
```
# .font200[works]
???
At this point you may be wondering how this all works.
So let's dig into some of the details.
---
class: center, middle
background-color: #FFFFFF
# Open source components
.leftcol40[.noborder[
<center>
<img src="images/google-sheets-logo.png" width=500>
</center>
]]
.columnnarrow[<br><br>
# .font200[`r fa("plus", fill = "black")`]
]
.rightcol40[.noborder[
<center>
<img src="images/opencpu.jpeg" width=300>
</center>
# .font150[OpenCPU]
(Thanks to Jeroen Ooms! [`r fa("twitter", fill = "blue")`](https://twitter.com/opencpu))
]]
???
Surveys in formr are built using open source components
The text and code for each survey are input using Google sheets,
and once the survey is live, R code is computed using Open CPU.
This makes it really easy to make your work as transparent as you'd like.
---
class: center, middle
background-image: url(images/googlesheet0.png)
background-size: contain
???
Here is an example Googlesheet.
Each row is an item that will be displayed on the survey.
Each column controls what will be shown.
---
class: center, middle
background-image: url(images/googlesheet1.png)
background-size: contain
???
The "label" column is where you insert markdown or code chunks that you want to display in the survey.
---
class: center, middle
background-image: url(images/googlesheet2.png)
background-size: contain
???
The "type" column is where you set the type of each question to show.
You can choose from a long list of options, like multiple choice, text entry, or simply just display text or images.
---
class: center, middle
background-image: url(images/googlesheet3.png)
background-size: contain
???
Depending on the type of question, you may also have some options for respondents to choose from, like in a multiple choice question.
---
class: center, middle
background-image: url(images/googlesheet4.png)
background-size: contain
???
And you can also customize the look and feel with some styling options
It's analygous to a R Markdown document, where the style and question type columns are sort of like the YAML
And the label and choice columns contain the content you want to display.
---
class: middle
<center>
<img src="images/screenshot-upload.png" width=900>
</center>
???
Once you've got your spreadsheet ready, you can login to formr.org, input the link to your Googlesheet, and formr will convert it into a survey.
---
class: center, middle
background-image: url(images/screenshot-apple.png)
background-size: contain
???
The example I just showed generates a survey with multiple choice questions about apples that look like this in a web browser.
---
# .center[Use the {formr} package to get data]
.leftcol20[‍]
.leftcol60[
```{r, eval=FALSE}
library(formr) #<<
# Connect to formr
formr_connect( #<<
email = 'youremail@gmail.com', #<<
password = '*****') #<<
# Import raw data
raw <- formr_raw_results(survey_name = 'apples') #<<
# Save raw data
write_csv(raw, here::here('raw_data.csv'))
```
]
???
Once your survey is live, you can use the associated formr R package to import results as a nicely formatted data frame.
---
class: middle, center, inverse
# .font140[Showing randomized images]
<br>
# .font140[Timed, randomized quizzes]
???
Now that we know a little bit about how formr works, I'd like to show a couple examples of how I've used formr in my own work.
---
class: middle, center, inverse
# .orange[.font140[Showing randomized images]]
<br>
# .font140[Timed, randomized quizzes]
???
I'll start with an example showing people randomized images in a research method known as conjoint analysis.
---
class: center, middle
background-image: url(images/screenshot-conjoint.png)
background-size: contain
???
In conjoint surveys, you ask people to choose from randomized profiles of different products. You can then use that data to estimate their preferences for attributes of those products.
So, for example, if I wanted to know how people felt about the price or freshness of different apples, I could ask them to choose from profiles like this.
In each question, I'll randomly change the values in the profiles.
---
class: middle
.code80[
```{r, echo=FALSE, eval=FALSE}
design <- read.csv("https://raw.githubusercontent.com/jhelvy/formr4conjoint/master/survey/doe.csv")
head(design)
```
```{r, eval=FALSE}
#> type price freshness image respID qID altID obsID
#> 1 Gala 1.0 Excellent gala.jpg 1 1 1 1 #<<
#> 2 Gala 4.0 Poor gala.jpg 1 1 2 1 #<<
#> 3 Pink Lady 1.0 Excellent pinkLady.jpg 1 1 3 1 #<<
#> 4 Honeycrisp 2.5 Poor honeycrisp.jpg 1 2 1 2
#> 5 Red Delicious 2.5 Poor redDelicious.jpg 1 2 2 2
#> 6 Red Delicious 1.0 Excellent redDelicious.jpg 1 2 3 2
```
]
.noborder[
<center>
<img src="images/screenshot-conjoint.png" width=650>
</center>
]
???
And because I'm working in R, I can pre-define the profiles in a data frame.
So in this example, the three profiles shown are generated from the first three rows in this data frame.
---
class: middle, center, inverse
# .font140[Showing randomized images]
<br>
# .orange[.font140[Timed, randomized quizzes]]
???
I've also used formr to create timed, randomized quizzes for my classes.
---
class: middle
```{r}
q1a <- "What's your favoriate **animal**?"
q1b <- "What's your favoriate **color**?"
```
.leftcol[
### .center[Version A]
```{r, eval=FALSE}
q1_text <- sample(c(q1a, q1b), size = 1)
q1_text
```
```{r, echo=FALSE}
q1a
```
Display text:
```{r, eval=FALSE}
`r q1_text`
```
`r q1a`
]
.rightcol[
### .center[Version B]
```{r, eval=FALSE}
q1_text <- sample(c(q1a, q1b), size = 1)
q1_text
```
```{r, echo=FALSE}
q1b
```
Display text:
```{r, eval=FALSE}
`r q1_text`
```
`r q1b`
]
???
I do this by creating an "A" and "B" version of every question on a quiz.
Then I use the sample function to randomly select a version for each question.
In this example, you might be asked what's your favorite animal or what's your favorite color depending on which question is selected.
---
class: center, middle
.leftcol[.noborder[
<center>
<img src="images/screenshot-quiz1.png">
</center>
]]
.rightcol[.noborder[
<center>
<img src="images/screenshot-quiz2.png">
</center>
]]
???
With just a 5 question quiz, I can create 32 unique quizzes.
In this example, I've also added a timer so that the quiz will automatically submit when the time is up.
---
class: center, middle
background-image: url(images/screenshot-options.png)
background-size: contain
???
That's just a few examples of how I've used formr, but I encourage you to check out formr.org to see some of the other complex designs you can make, like longitudinal or diary studies with automated email and text message reminders.
---
class: center
.leftcol[
## Number of admin accounts
<center>
<img src="images/formr-admin-users.png">
</center>
]
.rightcol[
## Number of surveys taken
<center>
<img src="images/formr-users.png" width=510>
</center>
]
???
Today, over a million people have filled out a survey on formr.
And there's a growing user base with a very active support group, so you'll have the help you need to build whatever survey you want.
---
class: inverse, center, middle
background-image: url(images/blackboard.jpg)
# .font150[Thanks!]
```{r child="faces.Rmd"}
```
## https://formr.org/
.footer-large[
.right[
[@johnhelveston `r fa(name = "twitter", fill = "white")`](http://twitter.com/johnhelveston)<br>
[@jhelvy `r fa(name = "github", fill = "white")`](http://github.com/jhelvy)<br>
[@jhelvy `r fa(name = "weixin", fill = "white")`](http://www.box.jhelvy.com/docs/jhelvy.png)<br>
[jhelvy.com `r fa(name = "link", fill = "white")`](https://www.jhelvy.com)<br>
[jph@gwu.edu `r fa(name = "paper-plane", fill = "white")`](mailto:jph@gwu.edu)
]]
???
So head on over to formr.org, and start making some R-powered surveys!