A Shiny Intro Survey to an Open Science Course

[This article was first published on An Accounting and Data Science Nerd's Corner, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Last week, we started a new course titled “Statistical Programming and Open Science Methods”. It is being offered under the research program of TRR 266 “Accounting for Transparency” and enables students to conduct data-based research so that others can contribute and collaborate. This involves making research data and methods FAIR (findable, accessible, interoperable and reusable) and results reproducible. All the materials of the course are available on GitHub together with some notes in the README on how to use them for self-guided learning.

The course is over-booked so running a normal introduction round was not feasible. Yet, I was very interested to learn about the students’ backgrounds with respect to statistical programming and their learning objectives. Thus, I decided to construct a quick online survey using the ‘shiny’ package. In addition to collecting data, this also provided me the opportunity to show-case one of the less obvious applications of statistical programming.

The design of the survey is relatively straightforward. It asks the students about their familiarity with a set of statistical programming languages and then changes the survey dynamically to collect their assessments about their usability and how easy they are to learn. After that, it presents a list of programming-related terms and asks students to state whether they are reasonably familiar with these terms. It closes with asking students about their learning objectives for this course and gives them the opportunity to state their name.

Screen shot of survey page

Screen shot of survey page

The data is being stored in a SQLite file-based database in the directory of the shiny app. Another app accesses the data and presents a quick evaluation as well as the opportunity to download the anonymized data. You can access the survey here (submit button disabled) and the evaluation app here.

Screen shot of evaluation page

Screen shot of evaluation page

To visualize the learning objectives I used the ‘ggwordcloud’ package. Fancy looking but of limited relevance.

One of those word clouds

One of those word clouds

The code for the survey and its evaluation is part of the course’s GitHub repository. Feel free to reuse. Some things that might be relevant here:

  • Watch out for SQL Injection issues. In my code, I use DBI::sqlInterpolate() for this purpose.
  • The repository contains both shiny apps (app_survey.R and app_results.R) in one directory. Make sure to export them as two separate shiny apps in separate folders.
  • Your result app needs to have access to the database file that the survey app is writing to. When you are hosting this on your own shiny server this can be realized by the results app linking to the database file in the folder of the survey app. If you plan to host your apps on a service like ‘shinyapps.io’ then this will most likely not be feasible. In this case, you might consider switching to an external database.
  • When using shiny in very large courses, your students might experience “Too many users” errors from shiny as it has a limit of 100 concurrent users for a given app. When running your own shiny server you can configure shiny to allow more users but my guess is that you will run into performance issues at some point.

This is it. Let me know your thoughts and I would be very happy to get in touch if you are reusing the code for your own class survey. Feel free to comment below. Alternatively, you can reach me via email or twitter.


To leave a comment for the author, please follow the link and comment on their blog: An Accounting and Data Science Nerd's Corner.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)