Chapter 11 Functions

A key element of programming: Writing our own functions, rather than using those written by others.

Please note: This chapter was originally placed before Chapter 10 on conditionals. But as functions often require conditionals, it makes more sense to start with conditionals and then proceed to functions.

Preparation

Recommended background readings for this chapter include:

Preflections

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

• What it the mathematical definition of a function?

• Which R functions have we been using so far? Where did they come from?

• Why would we want to write our own functions?

• What would we need to specify to commission (or document) a new function?