Introduction to programming in R

Open R Sessions 2024

Etka Yapar
Iain Moodie
Simon Jacobsen Ellerstrand
Violeta Caballero-Lopez
Ximena Alva Caballero

Introducing the Open R sessions

  • Who are we?
    • A group of PhD students who want to give all students the opportunity to learn how to programme (in R)
  • Why?
    • Programming in R is an incredibly useful skill as a biologist, and removes your reliance on expensive licensed software (e.g. SPSS)
  • What can you expect from this course?
    • We will cover all the basics of programming using R, which will provide a strong foundation for you to build on, whatever your interests/career path
  • What will we not cover?
    • Statistics (although we can probably still help out)

Introducing the Open R sessions

  • What is the format?
    • Course follows a logical order of progression, with each session building on the last
    • Each week starts with a short (15-30 min) lecture on a topic, followed by an exercise session on that topic (~1hr30)
    • During the exercise session, you can also bring your own questions / work on your own projects
  • All materials / lectures will be on Canvas
    • Follow in your own time, revisit topics, catch up on missed ones
    • Don’t worry if you can’t make it to all sessions!
  • No formal assessment or exams
    • No credits
  • Open R Sessions also runs “drop-in” only in the spring semester

Schedule

Date Time Session
2024-09-19 15:15 - 17:00 Introduction to R
2024-09-26 15:15 - 17:00 Data types and data handling
2024-10-03 15:15 - 17:00 Data visualisation
2024-10-10 15:15 - 17:00 Boolean operators
2024-10-17 15:15 - 17:00 For loops
2024-10-24 15:15 - 17:00 Open
2024-10-31 15:15 - 17:00 Functions
2024-11-07 15:15 - 17:00 Packages
2024-11-14 15:15 - 17:00 Tidyverse
2024-11-21 15:15 - 17:00 Open
2024-11-28 15:15 - 17:00 Open

The Open R Team

What is R?

What is R?

  • R is a programming language
    • A way of providing instructions to a computer
    • General features common to most programming languages
    • R specific syntax (grammer)
  • R is free and open source software (FOSS)
    • Anyone can download and use it, with no restrictions
    • Maintained by the R Foundation and the R Core Team
  • R is not just for statistics
    • Lots of statistical methods have been implemented in R
    • Fully featured programming language (can do anything, in theory)

What is R?

print("Welcome to the Open R Sessions!")
[1] "Welcome to the Open R Sessions!"
8 + 9
[1] 17
data <- data.frame(session = 1:11, ability = cumsum(1:11*0.9))
plot(data$session, data$ability, type = "b", xlab = "Session", ylab = "R Ability")

How to use R?

We use R via RStudio

RStudio

  • An IDE specially developed for R
  • If R is the engine, Rstudio is the rest of the car
  • Free
  • Very convenient for working with R
  • But remember, it is just a “layer on top”

So how do I get started?

  1. Download and install R https://www.r-project.org/
  2. Download and install RStudio https://posit.co/download/rstudio-desktop/
  3. When you want to use R, launch Rstudio.

Exercises

Exercises

  • Files on Canvas
    • Get R via RStudio up and running!
    • Get familiar with how to use R
    • Run some basic commands
    • Play some games!