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 to learn R. Thus, it may be hard to find learning resources that target Psychology researchers.
Table of Contents
Outline
The structure of this post is as follows. First, we start by getting a quick answer to the question “what is R?”. After this, we will briefly discuss good books you can use to learn R. In the next section, we will go into two other types of R resources: namely, tutorials and how-tos. This section will start by giving you some general resources and then list some R tutorials (many from this blog), and then, finally, you will get some Psychology specific R resources to learn from.
If you are new to R, you might wonder what R is. 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.
R Books for Psychologists
Recently I wrote about four good R books targeted at 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).
In the 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.
If you are new to R, you may want to start with R commander. This will provide you with a menu, making 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.
General R Resources
When starting off learning R any source may be useful. Here are some of the best R learning resources I’ve used:
- Quick-R: A comprehensive source for information on how to carry out many common statistical analyses as well as descriptive statistics and graphs.
- SimpleR notes for introducing the use of R for an introductory statistics course.
- The R Guide
- Cookbook for R provides solutions to many tasks and problems in data analysis.
- Revolution Analytics – A blog for news and information about R. Publishes guides and articles about R.
- R-bloggers A “blog aggregator” for R blogs. Here you can find and follow, a lot of comprehensive, basic and advanced, guides and posts.
- RStudio – my Integrated Development Environment (IDE) of choice when it comes to R.
R Tutorials:
Here are some of my own R tutorials that you may find useful. They cover everything from the basics (e.g., removing variables, descriptive statistics, data visualization) to more advanced topics (e.g., using other software and services for reproducible code).
- How to Use Binder and R for Reproducible Research – Learn how to use Binder together with R, and RStudio to create a fully reproducible computational environment.
- In the tutorial “R Excel Tutorial: How to Read and Write xlsx files in R” you will get a great overview of how to import Excel data into R.
- Data can be imported from other formats as well. Make sure you check out the posts about how to read a SAS file in R, read a SPSS (.sav) file in R, and import a stata (.dta) file in R.
- Learn how to create scatter plots in R will give you the skills to produce nice-looking data visualizations using the Tidyverse packages (e.g., ggplot2, dplyr, broom).
- How to use dplyr to remove columns by name and index in R is a very basic tutorial that will help you to remove variables from your dataset. For instance, you will learn how to drop a column using the variable name or the index.
- In the tutorial “How to Add an Empty Column to a Dataframe in R (with tibble)“, you will learn how to insert empty columns into the dataframe. It may be useful if you need to apply new values, cell by cell, to your dataframe.
- If you want to know how to e.g. calculate new variables check the post “How to Add a Column to a Dataframe in R with tibble & dplyr” out.
- There might be other data manipulation tasks that you might want to carry out before analyzing your data. See the post if you need to use R to remove duplicate rows and columns.
- In some cases, we need to change the name of the variables in our dataset. For example, if we are working together with other e.g. psychology researchers we may need to have variables that are clear so that they know what they are looking at. This is when you need to know how to rename a column in r.
- You may want to explore your data quickly using the five number summary statistics in R.
- How to Concatenate (or merge) Two Columns (or More) in R – stringr, tidyr
Checking Assumptions
IHere are some guides on how to check the assumptions of commonly used parametric tests:
If you are planning on carrying out regression analysis and you want to include categorical variables in your model you can check out the post about how to create dummy variables in R. This post will show you how to pre-process data so that you already have your indicator variabels when setting up your model.
R Functions
In this section, you will find links to my blog posts about some of the base R functions that you may find useful for e.g., data manipulation, data cleaning, simulation, exploration, and so on. First, if you need to learn about how to use the repeat() function in R to do some basic repeated calculations, or, how to simulate data using R’s simulate() function, check the post out.
- How to use %in% in R: 7 Example Uses of the Operator – will show you 7 examples on when this excellent operator can make your life easier!
- Learn how to transpose data in R in the post “How to Transpose a Dataframe or Matrix in R with the t() Function“
- How to Generate a Sequence of Numbers in R with :, seq() and rep() will show you how to create sequences that can be used for e.g. creating unique IDs for observations.
- In a recent post, you will learn how to use $ in R. This post will show you, by example, how to use this very basic and useful operator.
Extracting time, day, and year from date in R
If you are working with time series data you might sometimes need to separate the different pieces of a date (e.g., year) to carry out your data analysis (e.g., time series). Here are some tutorials showing you how to split a date into different parts:
- In the tutorial “How to Extract Time from Datetime in R – with Examples“, you’ll learn how to extract timestamps from date.
- How to Extract Day from Datetime in R with Examples
- In the tutorial, “How to Extract Year from Date in R with Examples“, you will learn how to get year from date.
Psychology R Resources
If you are a psychology researcher aiming to learn R it can be helpful to learn from other psychologists more experienced with the R statistical language. There are also some r-packages that are developed for psychology researchers.
- Using R for Psychological Research – here you will find many tutorials for using R in psychological research. These are very pedagogical and helpful. Here you also find the homepage of the great r-package psych.
- Notes on the use of R for psychology experiments and questionnaires
- Learning Statistics with R free draft of a book for learning R. It mainly covers frequentist methods but has a chapter of Bayesian statistics.
- Psychometric Models and Methods a brief overview of packages that are closely related to psychometrics. Used to teach statistics to Psychology students.
- Mixed Psychophysics – aims to give statistical tools (i.e., R code, models, tutorials, and links to articles) for psychophysics. It contains a short tutorial covering Psychometric functions, generalized mixed models (GLMM).
- The Psycho Blog. Here you will find some great blog posts and a very useful R-package called Psycho.R! It will make doing some of the most common statistical methods in Psychology easy to carry out using R.
If you are interested in learning how to reverse scores using R see the blog post “Reverse Scoring Using R Statistical Environment“.
Conclusion
Although, the learning curve for software such as R is steeper than using software with graphical interfaces (i.e., SPSS, Stata, and Statistica) it is not super hard to learn to carry out the most basic and classical statistical tests. If you aim for reproducibility learning R and/or LaTeX or RMarkdown is really the way to go. Hope you found some of the R resources useful. If you have any other resources that you think should be added (especially when it comes to Psychology related) please drop a comment below or use the contact page.
Note, Python is another great, and more general, programming language that may prove useful for an experimental psychologist (e.g., programming experiments). See my newer posts on how to carry out data visualization, data analysis, data manipulation, and more using Python:
- A Basic Pandas Dataframe Tutorial for Beginners
- How to Use Binder and Python for Reproducible Research
- Data Manipulation with Pandas: A Brief Tutorial