# A tibble: 3 × 2
species n
<fct> <int>
1 Adelie 152
2 Chinstrap 68
3 Gentoo 124
R, RStudio, & Posit.cloud
Wednesday, 19 August 2026
At the end of this topic you should be able to
Understand the main features of the RStudio IDE
Run simple R commands in RStudio
Understand the basic syntax of R
Understand how to use the R help system
R is a powerful software application for statistical analysis
It is incredibly popular
R is an interpreted language unlike C, C++, etc
Slower but more forgiving and interactive
RStudio is a powerful integrated development environment (IDE) for R
It is also open source
RStudio ≠ R
Can run RStudio on your computer or in the cloud using posit.cloud
RStudio PBC provide paid-for support & Pro-level versions for organisations
# A tibble: 3 × 6
species bill_length_mm bill_depth_mm flipper_length_mm body_mass_g year
<fct> <dbl> <dbl> <dbl> <dbl> <dbl>
1 Adelie 38.8 18.3 190. 3701. 2008.
2 Chinstrap 48.8 18.4 196. 3733. 2008.
3 Gentoo 47.5 15.0 217. 5076. 2008.
Don’t worry! You won’t understand most of that!
By the end of the course you will
<- is the assignment operator
Made up from the < and - characters
output <- input
Assign the result of the right hand side to the object named on the left
This creates an object with name output
Refer to objects using their name
The main data types in R are
' or double " quotesTRUE and FALSEAs well as <- R has many operators
Mathematical
+-*/Boolean
< and >
<= and >= (< = & > =)== (= =)!= (! =)& AND| OR! NOTCan get help on R from many places
Inside R use ?topic to get help on topic topic
Usually topic is a function
Can search more broadly with ??topic
Other sources:
Vectors are the fundamental way that data are stored in R
R doesn’t have scalars — single values — just vectors
Vectors are a one-dimensional collection of values in a single unit
(But see lists later in the course)
Atomic vectors are vectors whose elements are all of the same type
Create vectors with c() (for combine)
[1] 1 4 6 10
[1] "Alice" "Bob" "Claire" "David"
Number of elements via length()
Many other ways: seq(), rep()
Vectors are a power feature of R as they allow us to write more expressive code
In other languages, to achieve this you might have to loop (iterate) over the indices of the vectors to add each pair of elements in turn
We’ll talk more about loops and iteration later in the course
What if we have vectors of different lengths?
Warning in v1 + v2: longer object length is not a multiple of shorter object
length
[1] 2 5 6 3 6
v2 is recycled until it is of the correct length
Dangerous & powerful — best avoided
Working with data frames helps avoid this
Most functions in R accept vectors as inputs
Having stored data in a vector we might want to access certain elements of the vector
If we give the elements of the vector names we can index using those
We can also use a logical vector to select (TRUE) or exclude (FALSE) elements
Alice Bob Claire David
10 5 2 4
[1] TRUE TRUE FALSE FALSE
Any expression that evaluates to
can be used to index a vector
A function is
NULL, may be invisibly)seq(), length() etc are all functions
Functions typically take arguments — like flags for the CLI commands
n is an argument to runif
digits is an argument to round
Arguments can be matched by name or position
Don’t name the first argument but name everything else
R comes with a lot of functions
But it’s not comprehensive
R packages extend R with new functions that implement new statistical methods, utilities, or even entirely new domain specific languages
R packages are user-written and work just like those provided with R
Packages are typically installed from CRAN
Comprehensive R Archive Network
Packages are installed on to a computer into a library
Install a packages using
Load a package each time you want to use it with
(Other repos are available, like GitHub, esp for development versions)