In this post we will learn how to carry out repeated measures Analysis of Variance (ANOVA) in R and Python. To be specific, we will use the R package afex and the Python package pingouin to carry out one-way and two-way ANOVA f or within subject’s design. The structure of the following data analysis tutorial is as follows; a brief introduction to (repeated measures) ANOVA, carrying out within-subjects ANOVA in R using afex and in Python using pingouin. In the end, there will be a comparison of the results and the pros and cons using R or Python for data analysis (i.e., ANOVA).

# Category: R

R statistical programming related stuff

**Good resources** for learning R as a Psychologist are hard to find. By that I mean that there are so many great sites and blogs around the internet to learn R. Thus, it may be hard to find learning resources that targets Psychology researchers.

Recently I wrote about four **good R books** targeted for **Psychology students** and researchers (i.e., R books for Psychologists). There are, however, of course other good resources for Psychological researchers to learn **R programming**.

Therefore, this post will list some of the **best blogs** and **sites** to learn R. The post will be divided into two categories; **general **and Psychology focused R sites and blogs. For those who are not familiar with R I will start with a brief introduction on what R is (if you know R already; click here to skip to the links).

## What is R?

R is a **free **and** open source **programming language and environment. **Data analysis** in R is carried out by writing **scripts** and **functions**. Finally, R is a complete, interactive, and object-oriented language.

In R statistical environment you are able to carry out a variety of statistical and graphical techniques. For instance, linear and nonlinear modeling, classical statistical tests, time-series analysis, classification, and many more can be carried using both frequentist and Bayesian paradigms.

You may want to start with R commander. It provides a menu which may make learning R a bit easier at the beginning. R can be downloaded here: The Comprehensive R Archive Network.

## R Resources

One of the main things that I like with R is the broad and helpful community. This also means that there are many good resources for learning the language.

R is a free and open-source statistical programming environment. Being open-source and free it has a large and helpful online community (for instance, see StackOverflow). When I went from carrying out analysis in SPSS to do them in R, I searched for good books targeted to Psychologists. The following 4 R books are useful and good for Psychologists that want to learn R.

The first book, Discovering Statistics Using R, may be a really good start if you are an undergraduate and have no experience of programming or statistics. The next two books are from intermediate to advanced level. The last book is, at the moment, free and is also a great introduction to statistics.

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. 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.

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

## Reverse scoring in R

Many instruments (i.e., questionnaires) contain 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”). These items need to be reversed so that the data will be correct later for statistical analysis.

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).