Press "Enter" to skip to content

Tag: R

Every Psychologist Should Learn Programming

The aim of this post is to show you why you, as a psychology student or researcher (or any other kind researcher or student) should learn to program. The post is structured as follows. First I start with discussing why you should learn programming and then give some examples when programming skills are useful. I continue to suggest two programming languages that I think all Psychology students and researchers should learn.

RStudio-like Python IDEs – Rodeo and Spyder

In this post I will discuss two Python Integrated Development Environments (IDE); Rodeo and Spyder. Both Python IDEs might be useful for researchers used to work with R and RStudio (a very good and popular IDE for R) because they offer similar functionalities and graphical interfaces as RStudio. That is, Rodeo and Spyder can both be seen as the RStudio for Python.

R from Python – an rpy2 tutorial

rpy2 Tutorial

Recently I found the Python module rpy2. This module offers a Python interface to R. That is, rpy2 enables us to use the power of R in Python!

Obviously; rpy2 requires that you have both R (version 3.2+) and Python (versions 2.7 and 3.3) installed.  There are pre-compiled binaries available for Linux and Windows (unsupported and unofficial, however). In this short tutorial, I will show you how to do carry out a repeated measures ANOVA (rmANOVA) using the r-packages ‘afex‘ and ‘emmeans‘, Python, and rpy2. The post is now updated and you will find a YouTube video going through the rpy2 examples found in this blog post. You will also find another YouTube Video in which you will learn two methods to show R plots inline in Jupyter Notebooks. Make sure you check them out!

Papaja – APA manuscripts made easy

Do you also find it time-consuming to make your manuscripts follow American Psychological Associations (APA) guidelines? Have you searched the internet for a good .docx/.doc APA template? After reading this post, you might not have to search any more. Papaja is an r-package that makes your manuscript conform to APA guidelines! In this post I am briefly going to describe the package and what I think of it.

Reverse scoring using R statistical environment

This post is my first on R and it will describe a method to reverse scores using R.

Reverse scoring

In many instruments (i.e., questionnaires) some items are phrased so that a strong agreement indicates something negative (e.g., “When there is music in the room I find it hard to concentrate on reading”). For more information on reverse scoring, please see my earlier post: Reverse scoring in Python.  Since I was more  familiar with Python  compared to R, and I had no a clue on how to do this in SPSS, I wrote a Python script. The Python script used a function that used Pandas DataFrame and it reversed the scores nice and quickly.

However, in R was pretty much as simple to do reverse scoring as in Python. In the following script a data frame is generated with column names (i.e., columnNames,’Q1′ to ‘Q6’) and some data is generated using replicate and sample (100 responses, on the 6 questions). After that you will find two methods, that are pretty much the same, for reversing the can be found. The methods only differ in how the columns are selected. The first are select based on the index of the column and the second select based on the column names to be reversed (might be preferable if you know the names of columns but not the indices).

R Script