4 Understanding the tools you’ll use: Functions
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 ...
Get Beyond Spreadsheets with R now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.