In this video we introduce the repeat and while loops. There are small differences in the syntax of the three types of loops in R, which may make one form more convenient than another in any given application. The repeat loop lacks a looping index or a built-in means of breaking the loop, so it requires the use of the break statement. The while loop lacks an index, but includes an automatic method of stopping its execution. The for loop includes both an index and an automatic stopping method. Despite these differences, each form of loop can tackle any particular repetitive execution task, so they are nearly interchangeable.
In this video the repeat and while loops are illustrated on an example that illustrates the Central Limit Theorem and which is similar to an example featured in the video, "Repetitive Execution - Part 1". You should follow
along with Examples 8a and 8b in Mod11Script.R when watching this video.
This video is essential viewing for the course.