Getting Started
Tools You’ll Need
Visual Studio Code
Visual Studio Code (VSC) is a text editor that is also a convenient way to view and organise your files. VSC has extensions for other programs that you will use use in this unit, such as RStudio, python and Copilot.
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).
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()
Command + Shift + C
on MacOS orControl + Shift + C
on 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:
Installing python
If you do not already have python3 installed, install it. Your mac might already have python2, but you should install python3.
Go to the website and download the installer.
https://www.python.org/downloads/
Save it anywhere on your computer. Open the installer and choose ‘Customize Installation’, accept the defaults and click ‘Next’, then select the folder where you would like to install the program. Don’t install it on a network drive or Dropbox folder or some other place prone to failure.
Setting up the chatbot
One way to access Microsoft Copilot is through Github. Copilot is a chatbot interface that accesses AI programs such as GPT, Claude and Gemini. If you sign up for Github and verify that you are a student, you can get access to Github Pro and Copilot. Go to Github and sign up for a student version of Github Pro.
In VSC, add the extension for Copilot. You can see the Copilot window in VSC by going to View -> Appearance -> Secondary Side Bar. The Copilot window appears in the bottom right. In the top left of this right hand side bar, there are three dots, which you can use to switch between the chat and ‘Open Editors’.