Getting Started

Tools You’ll Need

Excel

Excel is available on all computer laboratory PC’s and can be freely downloaded to personal devices here. You should already feel confident using Excel from your previous units, however if you need further guidance please visit UWA’s resources:

R

To get started with R, first download the base R system onto your computer. By itself, this provides a rudimentary console for interacting with the R programming language. For a more user-friendly experience, download the R Studio integrated development environment (IDE).

  • R can be downloaded here
  • R Studio can be downloaded here

Terminology

File types

In this unit you will largely be dealing with two kinds of ‘R files’:

  • R script files (e.g. Equations.R) and,
  • R project files (e.g. Module2Biogeochem.Rproj)

R scripts are the raw instructions that tell the R programming language what to do. Meanwhile, an R Project file simply creates an independent workplace environment for you to interact with and manage your scripts. It’s wise to create a new R Project file whenever you start working on a new project.

Functions and packages

Just like Excel, you can interact with your data using a variety of functions in R. Functions are the tools you use to get the job done. For example, the plot() function can be used to create graphs. R is an open source programming language, meaning anyone can create their own functions and bundle them up in a collection known as a package.

Comments

All programming languages allow the user to write comments on their code to assist in readability and structure. In R, a comment is defined as a line beginning with a #. Any characters written after the # are ignored by R and not executed. It’s good practice to get into the habit of commenting your R code as it will likely save you (or someone else!) a lot of time later down the track.

# This is a comment!
library(tidyverse) # You can load packages with the library() function

# Inspect your data with the head() function
head(iris)

# Create a graph using the ggplot() function
ggplot(data = iris, mapping = aes(x = Petal.Length, y = Petal.Width, colour = Species)) +
  geom_point() +
  theme_light()
To comment multiple lines of code at once in R Studio, pressCommand + Shift + Con MacOS orControl + Shift + Con Windows

Further R resources

If you want to learn more about R and the tidyverse packages, we recommend reading the following (free) textbooks:

Unzipping files

Many of the module resources found in this workbook are downloaded as ‘zipped’ (i.e. compressed) files. ‘Unzipping’ (i.e. extracting) these files is simple.

On MacOS, simply double click the ‘zipped’ file:


On Windows, click ‘Extract All’ and follow the prompt: