Resources

John Helveston | Using formr to create R-powered surveys with individualized feedback | RStudio

This talk demonstrates how the formr study framework extends the power and flexibility of R to surveys. Using R and RMarkdown code, researchers and teachers can use the formr platform to generate both simple surveys and complex studies with individualized feedback. The platform is built on a web-based application programming interface for R via OpenCPU, enabling complex features such as automated email and text message reminders, adaptive testing, graphical and interactive feedback, and integration with external data sources. In this talk, I introduce some of the formr basics and showcase two examples of how I have used it, including making conjoint surveys with randomized images and timed, randomized quizzes for my students. About John: John Paul Helveston is an Assistant Professor in the Engineering Management and Systems Engineering Department at the George Washington University. He studies technological change, with a particular interest in accelerating the transition to environmentally sustainable and energy-saving technologies. His research centers around how consumer preferences, market dynamics, and policy affect the emergence of critical technologies, such as electric vehicles and solar energy. He is an expert on China's rapidly emerging electric vehicle industry as well as the critical relationship between the US and China in developing and mass producing low carbon energy technologies. He applies an interdisciplinary approach to research, with expertise in discrete choice modeling and conjoint analysis as well as interview-based case studies. He has conducted extensive fieldwork in China, collaborating with colleagues at Tsinghua university, Beijing Normal University, and China's State Information Center on past projects. He is a fluent speaker of Mandarin Chinese and also an award-winning swing dancer. John holds a Ph.D. and M.S. in Engineering and Public Policy from Carnegie Mellon University and a B.S. in Engineering Science and Mechanics from Virginia Tech

image: thumbnail.jpg

Transcript#

This transcript was generated automatically and may contain errors.

Hi, I'm John Helveston, and thanks for tuning in to my lightning talk on how to make R-powered surveys with formr. If you're someone who has ever had to make a survey, chances are you've probably used something like SurveyMonkey or Google Forms, and these platforms work great for simple surveys. But what if you needed to make something that was a little more complex than what these platforms offer?

Well, thankfully, some really clever people made formr, which uses R and RMarkdown code to create rich, complex surveys. Now, just to be clear, I'm not one of those clever people. formr was actually developed by Ruben Arslan and Cyril Tata. I'm just a formr superfan, and I made this talk to share it with the rest of the R community and to demonstrate some of the cool things that you can do with it.

What formr can do

So what can formr do? Well, I kind of think of it like SurveyMonkey plus RMarkdown. You can use it to create simple surveys, but you can also use R code to generate a much richer set of features. For example, you could create interactive charts that survey respondents could then experience while taking the survey.

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.

How formr works

So at this point, you might be wondering how all this works. So let's dig into some of the details. 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 OpenCPU. This makes it really easy to make your work as transparent as you'd like.

So here's an example Google Sheet. Each row is an item that will be displayed on the survey, and each column controls what will be shown. The label column is where you insert markdown or code chunks that you want to display in the survey. 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 questions, text entry, or simply just display some text or images.

Depending on the type of question, you may also have some options for respondents that you want them to choose from, like in a multiple choice question. And you can also customize the look and feel with some styling options. It's kind of analogous to an RMarkdown document, where the style and question type columns are sort of like the YAML, and the label and choice columns contain the content that you want to display.

Once you've got your spreadsheet ready, you can then log in to formr.org, input the link to your Google Sheet, and formr will convert it into a survey. The example I just showed generates a survey with some multiple choice questions about apples that look like this in a web browser. Once your survey is live, you can then use the associated formr package to go import results in a nicely formatted data frame directly into R.

Examples in practice

Now that we know a little bit about how formr works, I'd like to show a couple examples of how I've used it in my own work. And I'll start with an example of showing people randomized images in a research method known as conjoint analysis. In conjoint surveys, you ask people to choose from randomized profiles of different products. You can then use that choice 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, and then in each choice question, I'll randomly vary the values that I'm showing them. Because I'm working in R, I can predefine all those profiles in a data frame. So, in this example, the three profiles shown are generated from the first three rows of this data frame.

I've also used formr to create timed randomized quizzes for my class. I do this by creating a 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. With just a five question quiz, I can generate 32 unique combinations of quizzes. And in this particular example, I've also added a timer so that the quiz will automatically submit when the time is up.

With just a five question quiz, I can generate 32 unique combinations of quizzes.

So 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 that you might want to make, like longitudinal or diary studies with automated email and text messaging reminders. 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 all the help you need to build whatever survey you want. So head on over to formr.org and start making some R-powered surveys.