R Companion for Intermediate Stats
This book is intended to serve as a guide for the R functions you will be running in PSYC 605. The statistics will be covered in class; this is to support your analysis using R. This is not intended to be an exhaustive guide to R but rather a tool to aid in your work.
For clarity’s sake, repeated tests between statistical techniques will be fully explained each time to prevent needing to reference prior chapters. For example, tests of normality will be fully explained for different t-tests and ANOVAs. This may be repetitive, but it also allows each chapter to be fully stand-alone.
When there is text typed like this, it is informational or descriptive, telling you how to do something.
Text that appears to be highlighted in grey, such as the function
mean(cars$cyl), is R code. This is used when referencing a specific function or portion of code.
You will also find longer bits of code that are set in to the main text, as below:
This offset code will often come with output below it, to allow you to see both the code and what, if anything, it generates. It will also be commented, as an example of best practice and to aid in explanation.
NOTE: While it is best practice in code to load all necessary packages at the start of the script, I will be loading in packages as we use them to illustrate what functionality we are using. I will, however, name all the packages we use in a particular chapter up front. Further, I do not include
install.packages() for every package that is used. If you don’t have the package, install it first.
Creation of this guide would not have been possible without the numerous R packages listed. Additionally, the following guides and open resources contributed to the completion of this guide, and are great resources to have available for further reference: