### Functions as Return Values (Introduction to Statistical Computing)

Lecture
11: Functions in R are objects, just like everything else, and so can be
returned by other functions, with no special machinery required. Examples from
math (especially calculus) of operators, which turn one function into another.
The importance of scoping when using functions as return values. Example:
creating a linear predictor. Example: implementing the gradient operator (two
different ways). Example: writing `surface`, as a two-dimensional
analog to the standard `curve`. The use of `eval`
and `substitute` to control when and in what context an expression is
evaluated. Three increasingly refined versions of `surface`,
employing `eval`. — R
for examples.

Introduction to Statistical Computing

Posted at October 05, 2011 11:50 | permanent link