This chapter did not discuss any new tidyverse package, but rather a basic notion of computer programming: A function is defined as a relation between inputs and outputs. When creating more complex programs, defining functions allows us to abstract procedures that we may want to use repeatedly.
After working through this chapter, you are able to
- explain what functions are and why they are useful,
- use base R to define new functions,
- describe and check functions,
- control the flow of information by using conditional statements.
Take a look at the R Studio Cheat Sheets on Base R and Advanced R on Functions to check which commands you are now familiar with and which others you can still discover in the future:
Let’s test the functionality of our knowledge and skills on functions by completing the following exercises.