Chapter 25 Why write functions?
Much of the heavy lifting in R is done by functions. They are useful for:
Performing a task repeatedly, but configurably;
Making your code more readable;
Make your code easier to modify and maintain;
Sharing code between different analyses;
Sharing code with other people;
Modifying R’s built-in functionality.