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:
Chapter 11: Functions of the ds4psy book (Neth, 2021).
Chapter 19: Functions of the r4ds book (Wickham & Grolemund, 2017).
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?