2.1 Introduction

This chapter does two things. It introduces the programming language R and some of the basic principles of working with it. Then, it loads in a dataset from a study, and goes through how to do the basic initial work you should always do first: checking what variables you have, and generating descriptive statistics.

This and all subsequent chapters feature R code. I recommend you have a computer open and try all the code yourself. Don’t just run the code I quote; try variants and extensions for yourself. I won’t usually show the output of my code (it would take up too much space). Make sure the output you get makes sense to you. If some code does not work for you, retype it or break it down into its parts. If you are already an R user, you can probably skip straight to 2.4.