Control Statements: For Loop, If, Else 

To use simple yet useful control statements: for loop and if and else.

This tutorial will teach you the basics of R. It is not necessary to have any prior programming experience.

Let’s just say you need to check through a column vector of data values to see if it meets a certain condition or only executes a function if it means a certain condition. In this example, we need control statements that allow us to control the flow of a program.

There are quite a few control statements you can learn in programming, but the most useful and simplest control statements are the “for loop” statement, the “if” and “else” statements.

To get started watch the video

In the next video, you’ll learn how to create your own function, so you can make use of repeatable code.