- There are two types of functions
- closures
- primitives
- Primitives are implemented in
C
and cannot be created by the user - Closures can be created using the primitive function
function
c(mode(`function`), typeof(`function`), mode("function"))
## [1] "function" "special" "character"
- A closure has three parts
- formal arguments: variables passed to the function for it to use
- body: an R expression, or several expressions enclosed in
{ }
- environment - current environment when function is created (more on this later)