R is a free software environment for statistical analysis and graphics. **RStudio** is a user interface through which to use **R**. **RStudio** adds functionality that make working with **R** easier, more efficient, and generally more pleasant than working in **R** alone.

You can get started with R and RStudio by completing this tutorial (includes videos):

`adventr`

?The `adventr`

package contains a series of interactive tutorials that teach **R** alongside chapters of my 2016 textbook An Adventure in Statistics: the reality enigma. The tutorials are written using a package called learnr. Once a tutorial is running it’s a bit like reading a book but with places where you can practice the R code that you have just been taught. The `adventr`

package is free (as are all things **R**-related) and offered to support tutors and students using my textbook who want to learn R.

`adventr`

The package was written initially to support my own teaching on a module where I base the content around An Adventure in Statistics. One quirk of this is that there are some advanced tutorials on topics not covered in the book (but continue the themes of the book …). Another quirk is that - at present - there are some chapters that don’t have associated tutorials (for example, the Chapter on probability).

The tutorials are named to correspond (roughly) to the relevant chapter of the book. For example, *adventr_03* would be a good tutorial to run alongside teaching related to chapter 3, and so on.

**adventr_02**: Data basics in R and RStudio**adventr_03**: Summarizing data (introducing ggplot2)**adventr_04**: Fitting models (central tendency)**adventr_05**: Presenting data (summarizing groups and more ggplot2)**adventr_08**: Inferential statistics and robust estimation (covers Chapter 9 too)**adventr_11**: Hypothesis testing**adventr_14**: The general linear model**adventr_15**: Comparing two means**adventr_15_rm**: Comparing two means (repeated measures)**adventr_16**: Comparing several means**adventr_16_rm**: Comparing several means (repeated measures)**adventr_17**: Factorial designs**adventr_mlm**: Multilevel models (not covered in the book)**adventr_growth**: Growth models (not covered in the book)**adventr_log**: Logistic regression (not covered in the book)

`adventr`

To use `adventr`

you first need to install **R** and **RStudio**. To learn how to do this and to get oriented with **R** and **RStudio** complete my interactive tutorial, getting started with R and RStudio.

Once you have installed **R** and **RStudio** you can install `adventr`

. The package is in development so you have to install it from github. To install the package execute (in **RStudio**):

```
install.packages("remotes") #if you don’t already have it installed
library(remotes)
remotes::install_github("profandyfield/adventr")
```

To run a particular tutorial execute:

```
library(adventr)
learnr::run_tutorial("name_of_tutorial", package = "adventr")
```

and replace “name of tutorial” with the name of the tutorial you want to run. For example, to run tutorial 3 (for Chapter 3) execute:

`learnr::run_tutorial("adventr_03", package = "adventr")`

The name of each tutorial is in bold in the list above. Once the command to run the tutorial is executed it will spring to life in a web browser.

The tutorials are self-contained (you practice code in code boxes) so you don’t need to use RStudio at the same time. However, to get the most from them I would recommend that you open two RStudio sessions (i.e. two RStudio windows running simultaneously). Use one RStudio session to run the tutorial. You won’t then be able to use this RStudio window (because its resources are allocated to the tutorial). In the second RStudio session try replicating what you learn in the tutorial. That is, open a new script file and everything you do in the tutorial, practice in the script file (and save it). This workflow has the advantage of not just teaching you the code that you need to do certain things, but also provides practice in using RStudio itself.

Here’s a video explaining how I use the tutorials within my own classes:

- The tutorials typically follow examples described in detail in (Field 2016), so for most of them there’s a thorough account in there. You might also find (Field 2020) useful for the
**R**stuff. - There are free lectures and screencasts on my YouTube channel
- There are free statistical resources on my website www.discoveringstatistics.com

- R for data science is an open-access book by the creator of the tidyverse (Hadley Wickham). It covers the
*tidyverse*and data management. - ModernDive is an open-access textbook on
**R**and**RStudio** - RStudio cheat sheets
- RStudio list of online resources
- SwirlStats is a package for
*R*that launches a bunch of interactive tutorials.

Field, Andy P. 2016. *An Adventure in Statistics: The Reality Enigma*. London: Sage.

———. 2020. *Discovering Statistics Using R and RStudio*. 2nd ed. London: Sage.

Copyright © 2000-2019, Professor Andy Field.