R for Sport Scientists – Fundamentals Course
Lecture 5: Control Flow
In this lecture, I am going to show you how you can control the flow of the R program using choices and loops. Loops should be generally avoided in R (since they can be slow, and there are specialized functions and packages for looping through objects), but it is important to understand them since sometimes they cannot be avoided.
Before explaining choices and loops, in the first video, I will cover some basic input and output from/to the console.
The second video will cover flow control using choices (i.e., if and switch commands as well as vectorized if statement using ifelse).
In the third video, I will explain the loops using the for, while, and repeat commands.
The fourth video is reserved for a solution to the unseeing game problem that I have given as an exercise to do yourself. Please do not watch the fourth video before you tried to solve the problem yourself. Programming is learning by solving (your own) problems, rather than following solutions.
This topic contains 0 replies, has 1 voice, and was last updated by Mladen Jovanovic 1 year, 10 months ago.
You must be logged in to reply to this topic.