The power of R scripting – don't be afraid of code
R is a programming language for statistical analyses and data operations that may seem daunting at first, but is really compelling and elegant once you get used to it. And it can make your life so much easier. Here are the impressions of a newbie.
R is not for me, right?
I always thought R was for statistics nerds only, not to be used for analyses in “normal” UX research. But then I was forced to use it in a recent project and its power and elegance impressed me. How did I end up using R? We created a dashboard for one of our clients with various UX KPI across a range of products. The dashboard was created in Microsoft PowerBI, which provides great data visualization tools and allows the user to create custom analyses with a few clicks. But it does not do statistics well, relying on R integration instead.
Why R? Some examples
A couple of examples that make R such a pleasure to use:
- Typical procedures are super simple: calculating a KPI from multiple columns per participant is a one-liner because R treats data as vectors new_value <- rowMeans(…)
- Running different statistical tests depending on the data’s properties (e.g. sample size, distribution) is very easy: write your own function if (data property = X) return (statistical test Y) and use it throughout your code.
- Working with larger data sets is very convenient, because you can use subsets of data on the fly with the “subset” function.
- Data transformation is quick and powerful: Convert data from long to wide, differentiating separate measurements, with a function called “dcast”.
All of this is also possible in SPSS, but it would require a lot of clicking through dialogues and assistants. For somebody like me who isn’t much of a SPSS syntax pro, I was surprised how easy it was in R.
The power of the community
But of course, learning R meant a lot of questions – it’s not something you learn in an afternoon. However, R has such a large and helpful community that there’s almost always an answer out there. There are numerous pages that tell you about the basics of using R, and whenever I had a more specific problem, I would almost always find the solution in one of the many active online communities. Learning R might be a bit difficult, but you’re definitely not alone.
Packages for every occasion
The solutions you find online will often use so-called packages through which you can expand R’s features. And R being open source means there are packages for almost any occasion, created and verified by the community.
R in a nutshell
R is a programming language that is free to use under the GNU licence. It comes with a broad set of statistical functions and can be expanded almost infinitely with the help of packages provided by the community. Development environments such as RStudio make life a lot easier.
My suggestion: Get RStudio, get real data to work with (to prevent playing around aimlessly), check out the tutorial pages and: have some patience!
Here you can find RStudio and tutorials:
Is R for me?
I probably wouldn’t have started using R had I not been “forced” to by PowerBI. But in retrospect, I’m glad I did! If you own SPSS, you won’t be using R for a quick mean or statistical test. However, if you know you’re going to be doing more extensive data transpositions and analyses, and potentially do them repeatedly, R might be worth looking into. Especially if SPSS seems to make what you are trying to do unnecessarily complex. I will definitely use R for future projects.