This chapter covers
- Repeating operations with functions
- The boundaries of where things are defined (scope)
- Messages, warnings, and errors, and how to deal with them
- Testing that your code does what you think it does
The true power of a programming language arises when you can tell the computer to do something and that request is simpler than just doing the work ourselves. Any time you want to calculate something more than once, it’s potentially a good idea to wrap the code up into a meaningful expression that can be reevaluated with a different (or even the same) input.
You’ll quickly see that functions are the standard method of achieving this goal in R. Once errors inevitably arise, you’ll ...