If you’re a survey analyst, you might be using the R programming language to clean, analyze, and visualize your survey data. Wouldn’t it be nice if there was a one-stop all-inclusive toolkit to do all of these things for your SurveyMonkey surveys? Look no further…
Our Research team at SurveyMonkey is proud to share version 1.0 of svmkR, an open-source R package that allows you to do end-to-end survey research.
All of the tools associated with the different stages of survey research are unified under a common interface and framework through our R package. We’ve stress-tested this framework with real-world projects ranging from election polling during the 2022 midterms with NBC and UPenn to tracking the spread of COVID-19 with Boston Children’s Hospital and Harvard Medical School.
How svmkR can make survey research easier
Our R package works as a wrapper around the SurveyMonkey Developer API with some additional capabilities to make every step in the survey research workflow easier. There are three major stages, in particular, that svmkR can help you conduct more efficiently: survey creation, survey weighting, and crosstab creation.
Import your questionnaire into SurveyMonkey automatically
At the very start of a survey research project, you probably start with a questionnaire document that you manually program into the SurveyMonkey platform. If your survey contains more than a dozen or so questions or if your particular project involves many surveys each with their own distinct questionnaire, this can tally up to a lot of work!
We designed a mark-up syntax called “QDOC” for questionnaire documents that makes it easy to import a questionnaire from Google Docs into a SurveyMonkey account. Below on the left is a snippet of a real questionnaire document for an election poll written up by SurveyMonkey researchers. On the right is the same questionnaire snippet marked up (in red) with a set of QDOC tags that specify exactly what kind of question is being asked, when the question text ends and the choices begin, and where the breaks between pages of the survey should go.
This precise mark-up allows your questionnaire to be more machine-readable and, therefore, directly upload-able into your SurveyMonkey account in just one step.
Generate customizable population weights for your responses
After you’ve uploaded and fielded your survey, chances are you might want to adjust your respondent composition to make it better resemble the target population you’re trying to reach. This process is known as “weighting,” and it often involves writing lots of code and making lots of decisions about which algorithm to use in order to weight your data, the specific dataset to use to capture your population distribution, and the specific questions to weight your survey with.
Luckily, svmkR does all of the heavy lifting for you: all you have to do is specify which target population data you’d like to use – in our running example, it’s the U.S. general population of adults as measured by the Census’s American Community Survey (ACS) in 2019 which is entitled “us_genpop_acs19” in our package – and let svmkR take care of the rest.
The weight_to function, denoted in the red box below, will automatically map the right survey questions to the right population variables (e.g. “What is the highest level of your educational attainment?” → the ACS educ variable), perform a standard raking algorithm in order to generate adjustment weights, and diagnose any issues along the way.
For more on how to create weights for your survey (and why you should), see this related blog post.
Create crosstab spreadsheets that summarize trends in your data
A common way to present key descriptive statistics in your data (e. g. “What percentage of women answered yes to this question?”) is with cross-tabulations of different variables.
Below is a snippet of code that demonstrates how to take your processed survey (after running my_cleaning_func shown in the previous image) and then turn it into some pretty crosstabs in Google Sheets with just three easy function calls.
And just like that, you have an informative set of color-coded, easy-to-read crosstabs ready to share with the world!
How to get started
To get started with the svmkR package, simply use the following function to call from the devtools package to install svmkR from its GitHub repository.