Chapter 10 Conditionals

This chapter starts a new part: Basics of programming.

Overview of chapters in this part:

  • Chapter 10 introduces conditionals (for distinguishing between cases)
  • Chapter 11 introduces functions (for creating our own functions)
  • Chapter 12 introduces iteration (for executing code repeatedly).

Conditional statements allow distinguishing between cases and perform corresponding computations. In both spoken and computer languages, such constructs are typically signalled by “if-then.”

Please note: This chapter was originally placed after Chapter 11 on functions. But as functions often require conditionals, it makes more sense to start with the latter.


Recommended background readings for this chapter include:


i2ds: Preflexions

To reflect upon the notion and uses of conditionals, try answering the following questions:

  • What is the function of if-then statements?

  • What feature could serve the same function? (Hint: Think base R…)