Description Usage Arguments Details Technical details References See Also Examples
These functions provide the base mechanisms for defining new functions in the R language.
1 2 |
arglist |
Empty or one or more name or name=expression terms. |
expr |
An expression. |
value |
An expression. |
The names in an argument list can be back-quoted non-standard names (see ‘backquote’).
If value
is missing, NULL
is returned. If it is a
single expression, the value of the evaluated expression is returned.
(The expression is evaluated as soon as return
is called, in
the evaluation frame of the function and before any
on.exit
expression is evaluated.)
If the end of a function is reached without calling return
, the
value of the last evaluated expression is returned.
This type of function is not the only type in R: they are called closures (a name with origins in LISP) to distinguish them from primitive functions.
A closure has three components, its formals
(its argument
list), its body
(expr
in the ‘Usage’
section) and its environment
which provides the
enclosure of the evaluation frame when the closure is used.
There is an optional further component if the closure has been byte-compiled. This is not normally user-visible, but it indicated when functions are printed.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
args
.
formals
, body
and
environment
for accessing the component parts of a
function.
debug
for debugging; using invisible
inside
return(.)
for returning invisibly.
1 2 3 4 5 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.