The R language revolves around two fundamental components: objects and functions. Objects are the data structures used to store information, while functions are the tools used to manipulate these objects. As paraphrased from John Chambers, one of R’s originators, “everything that exists in R is an object, and everything that happens is a function.”
Mastering the creation and use of functions enables automation of repetitive tasks, enhances efficiency, and reduces coding errors.
Through this lesson, I have gained the ability to:
- Create and use custom functions in R.
- Design function arguments and define default values.
- Incorporate conditional logic, such as
if
,else if
, andelse
, within functions. - Validate function arguments to prevent errors.
- Manage function scope and understand the differences between local and global variables.
- Work with vectorized data within functions.
- Organize and store custom functions for future use.
For further review, check here.