R control flow loops and functions

Open to
Government analysts
Training category
Analytical, Data science
Type of training
3 hours
Data Science Campus Faculty
Data Science Campus Faculty

Loops, Control Flow and the ability to write your own functions are valuable programming tools. By using these tools you can help to reduce repetition in code. This improves readability and ensures you are following good coding practices. This short course introduces these topics and demonstrates areas for additional learning.

Who this course is for

To enrol on this course you will need to have completed the “Introduction to R” course.

Learning outcomes

On this course you will learn:

  • about the programming concept of Loops
  • how to use loops and understand their place in R
  • how to use conditional statements, such as “if”, “else”, and “else if”
  • about “else_if()” and “case_when()” from
  • what functions are and why they are useful
  • how to tell the difference between a function’s parameters and arguments, including different types of arguments
  • about idea of “scope” — for example, Global scope vs Local scope
  • how to write and apply user defined functions
  • how to apply functions to vector and tibble objects

How to book

Please use your Learning Hub account to access this course online. If you do not have a Learning Hub account, please contact Data.Science.Campus.Faculty@ons.gov.uk.


If you would like more information about this course, please email Data.Science.Campus.Faculty@ons.gov.uk. 

Related courses

Python control flow loops and functions