The Benefits of Running R Scripts on Survey Data
What is R?
R is a cost-effective tool that can be tailored to perform all kinds of quantitative research.
More specifically, R is a programming language that can easily be incorporated into a complex toolchain. It’s used by millions of statisticians, institutional researchers, data scientists, and researchers around the world for the purposes of data modeling and visualizations.
If you don’t have a background in data analysis or programming, you might be intimidated by the idea of learning how to leverage R — specifically R scripts — for your survey data analysis.
But fear not! By investing the time to get comfortable with running R scripts, you’ll be able to perform complex data analysis that will yield powerful insights.
Why is R So Popular?
It’s not by chance that R has become a go-to resource for researchers across industries.
Below are some reasons why R is so vastly used for data analysis and visualization.
- R is open sourced, so it’s 100 percent free to work with.
- R’s data visualization capabilities are best-in-class when it comes to statistical software.
- It’s easy to create thousands of packages in R. These packages are extensions to R that can be used across a wide variety of industries and roles.
- R has an incredibly active community that has created thousands of the packages mentioned above.
- R is thoroughly tested by its community of users, so you can apply their contributions to your own analytical processes to help extend your analysis beyond the functionalities provided by SPSS.
- R is an actual programming language with a command line interface for executing code, which is a huge step up compared to other point-and-click solutions.
The Components of R
In order to get comfortable with R in general, and R scripts in particular, it’s essential to familiarize yourself with the following components of R.
R’s Console allows you to execute R commands.
For a basic example, if you were to enter 3 + 3 into the Console, R would return 6 as a result.
R is more than just a scientific calculator. In it, you can create Variables.
A Variable allows you to store data in R for later use.
Creating a Variable is simple and straightforward — just type <- in R.
For example, let’s say we’re looking to define the dimensions of an imaginary rectangle. By inputting height <- 4, we’ve identified the height of the rectangle as 4. If we were then to input height later on in the Console, R would return the value of 4.
Similarly, if we input width <- 8, we’ve defined the width of the rectangle as 8.
Setting up variables, and continuing to do so, builds out the R Workspace. The Workspace is where R variables “live.”
By inputting ls(), R will present all of the variables that have been created thus far.
But let’s say that we want to calculate the area of a rectangle that has different height and width Variables than what have been previously defined.
In order to do this manually, we’d have to redefine both Variables in the Console, and then recalculate the area of the rectangle.
This process is manual and time consuming, and as a result things can get extremely confusing when working with multiple variables.
That’s where R scripts come into play.
What is an R Script?
An R script is simply a text file with successive lines of R code.
Using our example above, we could create an R script and call it rectangle.R.
Rectangle.R would look something like this:
Height <- 4
Width <- 8
Area <- height * width
By running this R script, R will go through your code line by line and execute every command one by one in the Console. This acts exactly the same as if you were to type each command yourself.
If we want to change our code, we can simply adapt our R script and run it again.
For example, we could change our R script so that height <- 5 and width <- 10.
When we rerun the script, the variables are given different values this time, and the output changes accordingly.
In this way, R scripts save researchers and data analysts an immense amount of time by automating work that would otherwise have to be done manually. This provides researchers with the flexibility to allocate resources to other tasks.
When to Use R Scripts
If you’re looking to perform a complex analysis of survey response data, you should consider running R scripts.
R scripts can be used for a wide variety of use cases, including but not limited to:
- Optimizing a financial portfolio
- Mapping marketing data
- Analyzing the outcomes of clinical trials
R scripts allow you to manipulate your data to develop predictive models and customized data visualizations in ways that SPSS simply cannot support.
In SurveyGizmo, if R scripts are enabled, they can be used in any Standard Report.
If you elect to do so, the R scripts will honor the report’s settings, styles, and filters.
The R script output can be in the form of:
- Custom Visualizations
…And all of these are rendered in real-time!
If you have customization ideas that you haven’t figured out how to tackle with R scripts, contact our Professional Services department. They have the R scripting chops to help you achieve your goals, and they’ll be able to answer any and all of your R script-related questions.
Have you benefited from running R scripts on your survey response data? If so, we’d love to hear from you! Drop us a note in the comments below.