retain                package:memisc                R Documentation

_R_e_t_a_i_n _O_b_j_e_c_t_s _i_n _a_n _E_n_v_i_r_o_n_m_e_n_t

_D_e_s_c_r_i_p_t_i_o_n:

     'retain' removes all objects from the environment except those
     mentioned as argument.

_U_s_a_g_e:

     retain(..., list = character(0), envir = parent.frame(),force=FALSE)

_A_r_g_u_m_e_n_t_s:

     ...: names of objects to be retained, as names (unquoted) or
          character strings(quoted).

    list: a character vector naming the objects to be retained.

   envir: the environment from which the objects are removed that are
          not to be retained.

   force: logical value. As a measure of caution, this function removes
          objects only from local environments, unless 'force' equals
          TRUE. In that case, 'retain' can also be used to clear the
          global environment, the user's workspace.

_E_x_a_m_p_l_e_s:

     local({
       foreach(x=c(a,b,c,d,e,f,g,h),x<-1)
       cat("Objects before call to 'retain':\n")
       print(ls())
       retain(a)
       cat("Objects after call to 'retain':\n")
       print(ls())
     })
     x <- 1
     y <- 2
     retain(x)

