Skip to Tutorial Content

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

Installing R and RStudio

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

  • The difference between R and RStudio and how they work together
  • Installing R
  • Installing RStudio

Video tutorial

Quiz

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

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

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

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

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

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

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.


  1. 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.

Getting started in R and RStudio

Andy Field