on.exit {base} | R Documentation |
Function Exit Code
Description
on.exit
records the expression given as its argument as needing
to be executed when the current function exits (either naturally or as
the result of an error). This is useful for resetting graphical
parameters or performing other cleanup actions.
If no expression is provided, i.e. the call is on.exit()
then
the current on.exit
code is removed.
Usage
on.exit(expr, add = FALSE)
Arguments
expr |
an expression to be executed. |
add |
if TRUE, add |
See Also
sys.on.exit
to see the current expression.
Examples
opar <- par(mai = c(1,1,1,1))
on.exit(par(opar))