Skip to content

rastlab/R_templates

Repository files navigation

This repo contains R templates for many of the core statistical analyses conducted by the Group Processes and Leadership Lab at the University of Alberta, which is directed by Dr. David Rast, III.

These R templates cover a lot of basic (read: typical) social psychology data analyses. Walks the user through importing data, cleaning data, running psychometric analyses, then finally analyzing the data using ANOVA or regression with appropriate interaction probing techniques.

Templates are numbered sequentially, but are only meant to assist the user through analyses in a logical and structured manner. The sequential order does not imply the user to go through each template in sequence, again these are starting blocks for users. For instance, if one's data are already 'tidy' then skip the '01_dataset_prep_and_cleaning.R' script.

We've tried to automate as much as possible to keep user errors to a minimum. We've also tried to keep as much as possible of the data output in R. For instance, figures and tables are created in APA format then automatically saved to your PC.

We've commented eavily throughout each script to help new users along where possible or to explain what a command does. As a side purpose, these templates were also written to help guide new R users through the stages of data analyses, especially those coming from SPSS. Many comments or functions are specifically for new users and people switching from SPSS.

NB: although we wrote these scripts, sections or entire parts might be modified from existing code posted online (e.g., Stack overflow, R blogs) or based on feedback/workshops from colleagues (e.g., Chris Aberson at HSU). We tried to cite these online sources where applicable by providing the link to the source material.

The GPL Lab regularly updates the code and adds new templates as we run new analyses or find new methods/packages to simplify the analyses/code.

If you have a template you want to add, feel free to send it to me. If we want to add it after reviewing/testing it, we will put it into our preferred (opinioned) format then upload it and attribute it to you.