seascape models

Survey your audience and visualise the results with R and Google forms

A quiz is a good way to engage your audience. Given I was giving a talk
about R datavisuals I thought it would be fun to visualise the quiz
results using R live with the audience. To top it off, we posted the
results to Twitter.

You could also use this system to survey our audience and share the
results live. Just prepare you R code and set it to run at a certain
time during your talk with a task scheduling algorithm.

Setting up the survey

I used Google Forms to do my quiz. You can take it
here.
I posed a few questions that challenged the audience to think about the
best way to visualise data.

It is pretty easy to set up a survey if you have a gmail account. A few
tips:

You can add images, which is great posing questions about results.

I used the ‘short answer’ input for numeric answers. If you click
the validation tab at the bottom of each ‘short answer’ question you
can require users enter certain types of numbers (e.g. within a
range).

Think carefully about limiting required inputs if you want to avoid
bugs that might arise from unexpected answers.

There is a green button at the top of the form that let’s you link
it to a google sheet. Do this.

You can make the sheet public, so other people can use it, but
changing the sharing settings.

Connecting to your survey answers in R

I used the googlesheets package to read my survey answers from the
(public) spreadsheet. You will need to authenticate yourself first:

library(googlesheets)
gs_ls()

This will prompt you to login to your google account and authenticate an
app that allows the connection to happen.

A boxplot of the audience’s guesses at my age by their position in the
room. I limited the y-axis because there were some outrageously large
numbers!

Share the results

We could show the audience the results on our screen. But why not let
Twitter know too!

For this, I used the rtweet package. rtweet is pretty simple to use
once you’ve set up an app on Twitter’s API and authorised R to access
it. So get rtweet then look at the vignette vignette("auth").
Follow the instructions to the letter and you shouldn’t have any
problems.

Once authorisation is done, its a simple matter to save our plot as a
png to use in a tweet:

Next steps?

So I tried this as a way of doing a live R tutorial. Next step would be
to try and integrate it into a talk without showing the R coding. For
that you would either need to get a friend to run the code or use a
scheduler (like the
taskscheduleR
R package).

Be careful though! You never know what answers people may give if
allowed. So design you code to be robust to strange answers (like that I
am 100 years old).