11.3 Summary

ds4psy: (11) Functions

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

  1. explain what functions are and why they are useful,
  2. use base R to define new functions,
  3. describe and check functions,
  4. 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:

Summary on functions from the [R Studio Cheat Sheet](https://www.rstudio.com/resources/cheatsheets/) on **Advanced R**.

Figure 11.2: Summary on functions from the R Studio Cheat Sheet on Advanced R.

Let’s test the functionality of our knowledge and skills on functions by completing the following exercises.