> 1 + 1
[1] 2
> 2 * 2
[1] 4
> 2 ^ 3
[1] 8
RAdelaide 2025
July 8, 2025
C
/C++
don’t allow for interactive analysisC
)Experience is the best teacher \(\implies\) please practice your skills
S
(Bell Labs, Chambers 1977)S
(Bell Labs, Chambers 1977)R
began to appear in 1996 (Ihaka and Gentleman 1996)
S
code \(\implies\) open-sourceR
is formally run by volunteers \(\implies\) R Core
ggplot2
\(\implies\) Create plots using the grammar of graphicsreadr
\(\implies\) Read files into R
install.packages("packageName")
will only install from CRANBiocManager
BiocManager::install("packageName")
installs from CRAN, Bioconductor & githubpak
also installs from multiple locationsR
as a standalone tool \(\implies\) open R
NOT RStudio
linux
: R
R
at it’s ugliest (how I learned R)R Console
R
is just a calculator (Press Enter)R
has many standard functions
We can create objects with names
x
<-
symbol is like an arrow i.e. “put the value 5
into x
”Console
x
only exists in the R Environment
Do R Objects Have Rules About Valid/Invalid Names
.
and _
+
, /
, *
, -
etc. are mathematical operatorsR
will think there are two objects.
or _
.
.
are often hidden from viewmy_object
) or camelCase (myObject
)x1
is a valid name whilst 1x
is notR Console
.Rhistory
in your working directoryR Studio
makes that easy & convenientR
type q()
Save workspace image? [y/n/c]:
n
then hit Enter.RData
in the folder we’ve been working in.RData
\(\implies\) can lead to dodgy analysis
R
and RStudio
are two separate but connected things
R
is like the engine of your carRStudio
is the ‘cabin’ we use to control the engine
R
that improve our ‘journey’R
does all the calculations, manages the data, generates plots
RStudio
helps manage our code, display the plots etc
RStudio
I use R Projects
to manage each analysis
RAdelaide25
in your home directoryRStudio
RStudio
will always open in a directory somewhereFiles
pane (bottom-right) to see where it’s lookinggetwd()
in the Console pane)R
We want RStudio to be looking in our new directory (RAdelaide25
)
\(\implies\)R Projects make this easy
File
> New Project
> Existing Directory
RAdelaide25
directory \(\implies\) Create Project
R Project
name is always the directory nameFile
> New File
> R Script
DataImport.R
This is the basic layout we often work with
bash
terminal (or PowerShell for Windows)Like we did earlier, in the R Console type:
Where have we created the object x
?
x
in our R Environment
Global Environment
R Environment
is like your desktop.RData
objectR
can be set to automatically save your environment on exitgit
tab will also appear for those who use git in their projectHelp
Tab for the sqrt()
function
base
base
is always installed and loaded with R
R
can be hit & miss
Help > Cheatsheets > RStudio IDE Cheat Sheet
Page 2 has lots of hints:
Ctrl + 1
places focus on the Script WindowCtrl + 2
places focus on the ConsoleCtrl + 3
places focus on the Help TabR
is the engine, driving everything we do