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 LinkedIn Learning 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!
# Create a graph using the plot() function
plot(my_data,variable1,col="red",ylab="My y-axis label")
# Plot other variables onto the graph using the points() function
points(my_data,variable2,col="blue")
points(my_data,variable3,col="green")
points(my_data,variable4,col="purple")
Command + Shift + C
on MacOS orControl + Shift + C
on Windows
Further R resources
- Read the Introduction to R and Statistics book for a more detailed coverage on the core data visualisation and statistics capabilities in R
- Access UWA’s LinkedIn Learning portal the learn more about the basics of R
- Refer to some handy R cheatsheets
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: