on.exit                 package:base                 R Documentation

_F_u_n_c_t_i_o_n _E_x_i_t _C_o_d_e

_D_e_s_c_r_i_p_t_i_o_n:

     '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.

     'on.exit' is a primitive function so positional matching is used
     and names of supplied arguments are ignored.

_U_s_a_g_e:

     on.exit(expr, add = FALSE)

_A_r_g_u_m_e_n_t_s:

    expr: an expression to be executed.

     add: if TRUE, add 'expr' to be executed after any previously set
          expressions; otherwise (the default) 'expr' will overwrite
          any previously set expressions.

_V_a_l_u_e:

     Invisible 'NULL'.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     'sys.on.exit' which returns the expression stored for use by
     'on.exit()' in the function in which 'sys.on.exit()' is evaluated.

_E_x_a_m_p_l_e_s:

     require(graphics)

     opar <- par(mai = c(1,1,1,1))
     on.exit(par(opar))

