Before you begin

  1. Download and install R
  2. Download and install R Studio
  3. Install the following packages using the prompt below
install.packages(c("dplyr", "lme4", "effectsize", "mediation", "ggplot2", 
									"psych", "emmeans", "lavaan", "readxl", "reghelper"))

Basics

R Markdown Interface

Blocks in the code

There will be grey blocks in R markdown which is where you write your R Code

Each block of code begins with something that looks like this

```{r exclusions} # the block and it's ouput will appear in full in your pdf
```{r exclusions, include = FALSE} # neither the block nor its output will appear
```{r exclusions, echo = FALSE} #the block will not appear but the output will 

The names of all of your blocks must be different in order to allow RMarkdown to print a pdf of your output. In the example above the name is “exclusions”. Never delete the “```{r”

R Basics

How do I tell R I want to work with a certain variable?

To refer to a variable in a dataset in R, you use the dollar sign. For example, if I want to use a variable called “normViolation_1” that comes from a dataset that I have called dta, then I would write

dta$normViolation_1