The term higher-order functions refers to functions that either take functions as arguments or return functions. The functions we used to create closures in Chapter 3 are thus higher-order functions. Higher-order functions are frequently used in R instead of looping control structures, and we will cover how you can do this in general in Chapter 6. A quick example is provided in this chapter before moving on to more interesting things we can do with functions working on functions.
The function sapply (it stands for simplifying apply) lets you call a function for all elements in a list or vector. ...