paleolimbot on GitHub

In the last lesson we covered expressions, variables, functions, vectors, and indexing, so now we're ready to learn about control structures, or the if, else, and for and while statements that let us control which code gets executed when. Finally, we'll learn about how to create our very own functions.

Operators

To be able to control which code gets executed when, we're going to need to be able to preform tests that return a TRUE or a FALSE. The operators R provides are what you would expect: they test for equality, inequality, greater than, less than, or if a vector contains an item (among others).

(Code)

Here is a summary of the most common operators.

Using the source window

Source window

If statements

If/else

Loops

for loop, while loop

Functions

defining functions