Introduction to R, RStudio and Quarto

Overview

R is a free software environment for statistical computing and graphics. It is what’s known as ‘open source’, which means that unlike commercial software companies that protectively hide away the code on which their software is based, the people who developed R allow everyone to access their code. This open source philosophy allows anyone, anywhere to contribute to the software. Consequently, the capabilities of R dynamically expand as people from all over the world add to it. In essence, R exists as a base package with a reasonable amount of functionality. Once you have downloaded R and installed it on your own computer, you can start doing some data analysis and graphs. However, the beauty of R is that it can be expanded by downloading packages that add specific functionality to the program. Commands in R are generally made up of two parts: objects and functions. These are separated by <-, which you can think of meaning ‘is created from’. As such, the general form of a command is:

name_of_object <- the_function_I_want_to_use()

Which means the object called name_of_object is created from the function that goes by the name of the_function_I_want_to_use. An object is anything created in R. It could be a variable, a collection of variables, a statistical model etc. Objects can be single values (such as the mean of a set of scores) or collections of information; for example, when you run an analysis, you create an object that contains the output of that analysis, which means that this object contains many different values and variables. Functions are the things that you do in R to create your objects.

The best way to learn R (in my opinion) is to install and work through one my packages of interactive tutorials. The adventr package aligns to the material in An Adventure in Statistics whereas the discovr package aligns to the material in Discovering Statistics Using R and RStudio. If you don’t own either of these books use the discovr package.

Interactive tutorials to learn R

Video tutorials

Getting Started in R

To help you set up and work with R I recommend working through these video tutorials, which introduce you to the workflow in RStudio cloud, and give you a tour of the RStudio app.

Workflow in Posit (RStudio) Cloud

Customizing RStudio cloud

Quarto

Quarto is used to create documents in RStudio. It combines standard word processing (similar to apps that you might already use such as MS Word) with coding to produce documents in which you integrate data processing, data visualisation, statistical modelling and interpretation. This series of videos helps you to get started using Quarto.

Quarto visual editor [Part 1]

Quarto visual editor [Part 2]

Quarto visual editor [Part 3]

Quarto visual editor [Part 4]

Quarto visual editor [Part 5]

LaTeX equations

Interacting with R

This series of videos looks at the basic principles of writing code in R and how to integrate R code into a Quarto document.

Coding in RStudio visual editor [Part 1]

This video looks at how to create objects and the structure of commands in R (i.e. the assignment operator, <-).

low=“accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture”>

Coding in RStudio visual editor [Part 2]

This video looks at what a function in R is, what an R package is, and how to install and use them. We look specifically at the here() function to give us a filepath.

Coding in RStudio visual editor [Part 3]

This tutorial explores using the pipe operator to combine functions together.

Coding in RStudio visual editor [Part 4]

This tutorial explores tibbles and how to render them using the kable() function.

Coding in RStudio visual editor [Part 5]

This tutorial revisits functions to look at what arguments within functions do. We also find out how energetic Iron Maiden songs are on average.

Coding in RStudio visual editor [Part 6]

This tutorial explores how code chunks are rendered in quarto documents and offers some tips on debugging errors when rendering goes wrong.

Continue Your Journey

Next topic