Introduction to loops
You will learn how to use operators, conditional statements, loops, and functions.
Before you start: R objects; indexing.
Setup: No data files are needed. Run setup and code blocks from the top of this page.
Your check: Connect comparisons, decisions, repetition and returned results. Practise in the unit summary.
At the end of this unit, you should know
- what arithmetic, relational, and logical operators do,
- how to use for loops,
lapply(), and while loops, - how to write if-then-else statements, and
- how to define and call your own functions.
Comments?
You can leave comments below if you have questions or remarks about any of the text or code in this unit. Please copy the corresponding line into your comment to make it easier to answer your question.