Search notes:

R: function

A function has three components:
A function is an object. This makes it possible to pass a function as arguments to other functions (such as lapply etc.).
R allows to define a function within a function.

Evaluation environment

When a function is called, an environment (the evaluation environment) is created in which the body of the function is evaluated.

Returning values

R does not have a return statement.
It has, however, a return function(?).
Thus, in order to use return, parenthesis are needed around the returned value.

See also

on.exit(…) allows to register a function to be called when a function exits.

Index