How to Use this Book

Instructor and Student Resources

Overview of the Book

The first portion of the book is devoted to introducing R and the benefits of R and Open Science. Then we provide instruction on how to run descriptive and inferential statistics in R.

For each analysis chapter we provide an .Rmd file with R code and text that is a standalone learning document. The instructions in the .Rmd file are provided to walk students through learning and using R for different descriptive and inferential statistics. We have found that this type of learning tool is often sufficient but many first time R-users want more instruction and interaction when working through .Rmd files. Thus, we also provide videos for each .Rmd file that provide additional detail about the .Rmd file and shows how to work through the file.

After working through each .Rmd example, students in our PSYC300: Research Methods courses apply what they have learned to their own research designs and data. Since this book is designed for use of R in an introductory research methods course, it focuses on how to clean and load data, visually explore it, run descriptive and inferential statistics and make pretty plots. We assume our readers are using RStudio and RMarkdown and make use of R packages, including the tidyverse.

Note that when working through the .Rmd files, R packages may need to be installed. Readers of this book and users of R in general should NOT quit R while installing or loading packages and libraries. This can corrupt crucial files. Instead, you can STOP the process (by clicking the red stop sign in the upper right corner of the console) and then quit the program, or wait until the process has been completed.

Chapter Outline

Chapters 1 and 2 of this book introduce R as well as motivate the usefulness and importance of learning R.

Chapter 3 continues the discussion of the importance of R within the broader context of open and ethical science practices.

Chapter 4 discusses how to access R.

Chapters 5 and 6 provide an introduction to the environment and basic language of R.

Chapter 7 - 8 provides an introduction to Excel and data cleaning and compilation in Excel.

Chapters 9 - 21 introduce how to use R for descriptive and inferential statistics. Each chapter has the following components and expectations:

  1. A link to the dataset and a .Rmd file students will use to make their own R Markdown file, following along to complete the learning outcomes.

  2. Multiple short videos that cover the .Rmd file content. These videos are short to help keep students engaged and motivated and encourage breaks.

  3. A table of contents at the start of each chapter aids in navigating through these separate sections.

  4. We start each lesson by going over the learning outcomes, reviewing the data we are working with, and installing and loading any necessary packages before providing new information.

  5. Students are expected to create, knit and submit their own unique R Markdown file using the example .Rmd file and working through the videos. In our classes, students will then create their own research designs, collect data and use the R examples previously worked through to now apply that knowledge to their own dataset.

Chapters 22 and 23 provide additional resources such as using ggplot to make publication quality visuals and R code cheatsheets.

Instructor Resources


What is provided:

The first portion of the book (chapters 1 - 8) is devoted to introducing R and Excel and the benefits of R and Open Science. Then we provide instruction on how to run descriptive and inferential statistics in R. For each analysis chapter we provide the following resources:

  1. A learning Rmd file. This is an Rmd file with R code and text that is a standalone learning document. There are instructions in the .Rmd file to walk students through learning and using R for different descriptive and inferential statistics.

  2. Short accompanying instructional videos. While we have found that the learning Rmd file is often sufficient as a standalone learning tool, many first time R-users want more instruction and interaction when working through .Rmd files. Thus, we also provide short videos for each .Rmd file that provide additional detail about the .Rmd file and shows how to work through the file.

  3. An Rmd analysis template file. When students are ready to run their own analyses, they can use an Rmd analysis template provided in each chapter. This template has the code needed to run the analyses covered in the chapter without the learning comments in the learning Rmd file.

  4. Teaching notes. For each chapter we will provide the assignment instructions we use when assigning chapters for review and knitting. If there are other teaching notes that may be applicable we also include them in the relevant chapters.

  5. Additional resources. Each chapter has additional resources at the bottom of each chapter.


How we teach R in our research course:

We follow the below format for teaching students to design research and analyze the data in R.

  1. Introduction and motivation to learning R and Excel (chapters 1 - 8).

  2. Read and view the videos for each analysis chapter (chapters 9 - 21).

  3. Knit the learning Rmd file for each chapter and submit for course credit. Please see the below assignment instructions to see how we assign and grade this portion of the course.

  4. Collect data with a particular research design (i.e., correlation, naturalistic observation, factorial experimental, etc.).

  5. Analyze this data using the Rmd analysis template.

  6. Students submit a write-up of their methods and data analysis.


Assignment Instructions: Knitting word documents from Rmd Learning Files Assignment

In order to earn the full credit on the knitted R file assignments, you must run the code in the .Rmd learning files and then knit the file. This is graded for completion such that if you run and complete all of the code sections you will earn the full credit. For example, if you run 9 out of 10 code sections you will earn 90%.

If a code section gives you an error or will not run, please do not comment it out without first trying to debug the problem and run the code! In order to earn the full credit for each code section it must run or you should troubleshoot by doing the following:

1) Document three unique things you did to debug the error. For each debugging attempt, please write out what you did (and specify the code) and what happened (and specify the output). You can use Google to help with this - if you copy and paste an error message into Google you will likely get some good advice!

2) Do this three times with three unique debugging attempts and write each attempt as a comment in your file, including the full error code from R. If this does not resolve the issue then you may comment out that code section and move on.

**Learning how to problem solve is a critical coding (and life) skill that we want to develop!

For more information on troubleshooting and de-bugging, review Ch. 6 of Learning R the EZ Way.

Student Resources

The first portion of the book (chapters 1 - 8) is devoted to introducing R and Excel and the benefits of R and Open Science. Then we provide instruction on how to run descriptive and inferential statistics in R. For each analysis chapter we provide the following resources:

  1. A learning Rmd file. This is an Rmd file with R code and text that is a standalone learning document. There are instructions in the .Rmd file to walk you through learning and using R for different descriptive and inferential statistics.

  2. Short accompanying instructional videos. While we have found that the learning Rmd file is often sufficient as a standalone learning tool, many first time R-users want more instruction and interaction when working through .Rmd files. Thus, we also provide short videos for each .Rmd file that provide additional detail about the .Rmd file and shows how to work through the file.

  3. An Rmd analysis template file. When you are ready to run their own analyses, you can use an Rmd analysis template provided in each chapter. This template has the code needed to run the analyses covered in the chapter without the learning comments in the learning Rmd file. You can use this template without using the Rmd learning file if you feel comfortable with the code.

  4. Additional resources. Each chapter has additional resources at the bottom of each chapter.