Coding, Database, R Language

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?

Plus

  • R code is quite similar to other programming languages, so if you have dabbled a bit in coding before it might be easier to understand than SPSS syntax (was for me).
  • Once you get the hang of it, analyses are super quickly done and the code can be optimized and reused later.
  • Graphical output is said to be more powerful and customizable than SPSS (not yet tested).
  • There’s a certain joy in doing complex data operations and statistical analyses with a couple of lines of elegant code – at least for me.
  • It’s free!

Minus

  • No graphical user interface, harder to learn because you need to code

 

Final words

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.

Author

Simon Harder

Simon’ ist seit 2011 als UX-Profi tätig, nachdem er seine Diplomarbeit über die Entwicklung eines UX-Messtools abgeschlossen hat. Seitdem hat er für SirValUse und die GfK an einer Vielzahl von lokalen und internationalen UX-Forschungsstudien in vielen Branchen gearbeitet. Bei uintent konzentriert sich bei Simon auf UX-Forschung, qual und quant.

Go back

Privacy settings

We use cookies on our website. Some of them are essential, while others help us to improve this website and your experience.
In this overview you can select and deselect individual cookies from a category or entire categories. You will also find more information about the cookies available.
Group Analyse
Name Google Analytics
Technical name _gat,_gtag_UA_120284862_1
Provider Google LLC
Expire in days 730
Privacy policy https://policies.google.com/privacy
Use Google cookie for website analysis. Generates anonymous statistical data on how the visitor uses the website.
Allowed
Group Essenziell
Name Contao CSRF Token
Technical name csrf_contao_csrf_token
Provider
Expire in days 0
Privacy policy
Use Serves to protect the website from falsification of cross-location inquiries. After closing the browser, the cookie is deleted again
Allowed
Group Essenziell
Name Contao HTTPS CSRF Token
Technical name csrf_https-contao_csrf_token
Provider
Expire in days 0
Privacy policy
Use Serves to protect the encrypted website (HTTPS) from falsification of cross-location inquiries. After closing the browser, the cookie is deleted again
Allowed
Group Essenziell
Name PHP SESSION ID
Technical name PHPSESSID
Provider
Expire in days 0
Privacy policy
Use PHP cookie (programming language), PHP data identifier. Contains only a reference to the current session. No information is stored in the user's browser and this cookie can only be used by the current website. This cookie is mainly used in forms to increase usability. Data entered in forms are e.g. B. stored briefly if there is an input error by the user and the user receives an error message. Otherwise all data would have to be re-entered.
Allowed
Group Essenziell
Name FE USER AUTH
Technical name FE_USER_AUTH
Provider
Expire in days 0
Privacy policy
Use Saves information of a visitor as soon as he logs into the frontend.
Allowed