Complementary materials for learning R - PSY 430

Course, University of Arizona, Department of Psychology, 2020

This post is meant to be a supplementary document for a course that I taught in 2020 Spring, PSY 430 Advanced Psychological Measurement and Statistics, in which students are expected to learn R along the discussion of statistic, research methods and psychological measurement.

In this document I list R materials that I found helpful for different areas of the application of R. I hope it can be helpful if you want to start using R or go deeper in a specific area, or maybe planning a course for your students.

I did not create the materials listed in this post. But rather, consider this post as a map that help you navigate the ocean of R materials out in the internet.

Basic info

If you are an absolute newbie and today is the first day of your R adventure, the official sites of R-Project and the RStudio are always good starts. Check out the Resources page of the RStudio site. They have plenty of good stuffs to help you get familiar with the RStudio environment and start playing with R.

Note: Not too uncommonly that beginners confuse R with RStudio, specially if R is your first experience with programming. R is a general purpose computing language, so in fact you can use R for almost everything (not that I think that is reasonable to do so). But RStudio is an integrated development environment (IDE) which provide the tools that help you use R more comfortably, at least as a beginner. So, please install R first and then the RStudio if you wish.

Getting to know R (or programming in general)

The first 6 chapters of The Art of R Programming explain basic data structure and programming in general very well.

This is definitely not the only R book out there but it is one of the bests I read, especially comes to explaining the details of R language that makes R nice for data analysis. It also provides the necessary programming background knowledge if you don’t already have it. The first 6 chapters of this book will probably give you enough background to understand most of the other materials and discussions online.

If you are one of those who want to know more about the tools they use, I think this book will be a good investment.

R for statistic analysis

There are quite many high quality R visualizations and discussion forum for learning intro statistic for social science. Some institutes and instructors are graciously offering their courses online for free access as well. Below are two that I found the most systematic and gave me a lot of cool ideas for teaching.

A group from the University of Oklahoma Political Science Department made their graduate methods course open source and freely available. Going through the materials step-by-step will be a great way to pick up basic R function and basic stat concept in the same time. All the materials will be applicable for the PSY 430 level and it is beautifully written, with embedded r code for analysis and visualization. Notice that it does not include contents like ANOVA and factorial analysis at the time of this post being written (April 2020).

Dr. Danielle Navarro at the University of New South Wales is working on a tutorial site for R for Psychological Science. Her tutorial in statistic is relatively more in depth, and her great project covers not just statistic, but also topics related to data science at broad. By the time of this post (April 2020) the site is still in progress but a lot of cool discussion on probability and introductory statistics are already available.

Some cool visualization sites for learning statistics

Dr. Kristoffer Magnusson’s RPsychologist.com is one of the most beautiful and interactive visualization collection you can find online. Don’t just take my words. Check out the following cool visualization and see it yourself:

On Statisitcla Power and Significance Testing

On Correlations and Shared variance

On Maximum Likelihood

A personal thank you is due and I really appreciate his work. It makes my class much more bearable and lot more productive.

Seeing Theory is a site built by a group from Brown University. The visualization is really fancy. I got the impression that the topics on this site are more oriented towards basic principles of statistics.

A deceptively simple site. The visualizations are designed for explaining 400 level statistics concepts so it is superb for in class lectures.

A site offers visualization that go beyond the realm of undergraduate level statistics.

Another site that has a pretty cool stat section but also goes beyond.

R for data handling

In real life, data manipulation (or data cleaning) goes hand-in-hand with data analysis and model building or testing. The handling of outliers, missing data, data types, transforming and jointing tables are no small things. I highly recommend the dplyr package and never regret the time spent learning it (plus, it really does not take that long to learn thanks to the well designed logic of the grammar). After getting familiar with the basic syntax of R, here are two brief blogs that can help you get going with dplyr:

If you want more and to build routine for best practices, here are one online data wrangling course and a book by the author of dplyr in data science best practice.

R for data visualization

Visualization with R is in-and-of itself a craft. Check out the R graph gallery to see what R is capable of doing. The ggplot2 package is popular for the data visualization in academic presentation and publication. The R for Data Science mentioned above has a chapter about ggplot2 which is a good start. Other freely available materials that I found helpful:

Also, interactive plotting with Plot.ly

R for presentation and reproducible document (fun stuff!)

It is a growing and exciting trend to use R and RMarkdown to generate reproducible/live document. It allows you to combine your writing and coding in the same document, and gives you most up-to-date results every time you compile your document without you copying the digits from one screen to the other. Seems too good to be true? Check out these cool (and still growing) packages out there:

  • Making conference posters with Posterdown

  • Making beautiful and code/equation-friendly slides with xaringan

  • Writing your APA formatted manuscripts with papaja

  • A gallery of RMarkdown generated live documents if you are still not convinced R Markdown Gallery

Also, there is always a free textbook if you decide to go the thorough route R Markdown: The Definitive Guide

R for programmers

When you are already having so much fun in R (or just mainly want to avoid the pain of repeating yourself), you might want to start writing your own R packages. Here are some info that might help you start:

If you are interesting in packaging your function is a more organized way, and focusing on having the most simple solution that works, maybe these blogs will be sufficient:

If you are really hooked, here are some more in-depth resources:

and finally, the R studio documentation:

The final remark

Since that the complete post functions as an index for all the wonderful and freely available resource online, I would like to spare my duty for an APA formatted reference list. All links are intact by the time of posting, and please let me know if some of the resource are not longer available and I will update as needed.

The R community (and the Open Source and Open Science communities as well) is great. I constantly found myself amazed by the generous contribution of so many brilliant scientists and coders. People are creating beautiful and powerful tools that make science more robust and fun - and they are striving to keep the products freely available. It is not perfect, but undoubtedly a beautiful endeavor.

Everybody, happy coding!