# Getting started in R and RStudio

## Overview

This tutorial is one of a series that accompanies the books An Adventure in Statistics (Field 2016) and Discovering Statistics Using R and RStudio (Field 2020) by me, Andy Field. This tutorial contains abridged sections from the books so there are some copyright considerations but I offer them under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License,^{1}

- Who is the tutorial aimed at?
- Anyone teaching from or reading Discovering Statistics Using R and RStudio or An Adventure in Statistics may find them useful.

- What is covered?
- This tutorial looks at using RStudio to interact with R. It covers installing R and RStudio, the difference between them, a tour of RStudio, good RStudio workflow practices, installing and loading packages, and using R Markdown. It would be a useful tutorial to run at the start of a module, or alongside teaching based on Chapter 1 of Discovering Statistics Using R and RStudio or or An Adventure in Statistics.

## Installing R and RStudio

This section looks at installing RStudio and R. The topics covered are:

### Video tutorial

### Quiz

## A quick tour of R Studio

This section takes a tour of R Studio. Topics covered are:

- The four panes of RStudio and changing their configuration
- Creating a new R Markdown document
- Getting help in R
- Changing the RStudio theme

### Video tutorial

### Quiz

## Working in RStudio

This section looks at good workflow practices in RStudio. The topics covered are:

- Using and creating R Studio project files
- Organzing your R Studio project folder
- Relative file paths
- Cuddling a spanial
- Creating a new R Markdown document
- Code chunks in R Markdown documents
- Loading data files

### Video tutorial

### Quiz

## Installing and loading packages

This section looks at installing and loading R packages. The topics covered are:

- R packages and the CRAN
- Installing packages using
`install.packages()`

- Loading packages using
`library()`

- Using a setup code chunk in R markdown
- Using the
`here`

package

### Video tutorial

### Quiz

## R Markdown

This section looks at creating documents using R Markdown. The topics covered are:

- What is R markdown?
- YAML (very briefly)
- Formatting text in R markdown documents
- Headings
- Bullet lists
- Emphasizing text (bold, italic, superscript, subscript)
- Inserting images/figures
- Inserting hyperlinks

### Video tutorial

### Quiz

## Getting data into RStudio

This section looks at how to use Microsoft Excel and Google sheets to enter data into RStudio. The video explains:

- What is
*tidy data*? - Entering data for independent designs using Excel/Google sheets and saving as a CSV file
- Entering data for repeated measures designs using Excel/Google sheets and saving as a CSV file
- Loading data from a CSV file into RStudio using
`readr::read_csv()`

### Video tutorial

### Quiz

## Tables in R Markdown

This section looks at how to format tables in R Markdown so they knit into beautiful things rather than horrific vomitoriums of plain text. The topics covered are:

- Setting code chunk options to
`results = 'asis'`

- Using the
`knitr::kable()`

function - Creating a caption
- Setting the number of decimal places for a table
- Using the
`kableExtra`

package to ceate banded/striped tables

### Video tutorial

### Quiz

## References

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

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

Basically you can use this tutorial for teaching and non-profit activities but do not meddle with it or claim it as your own work.↩