home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Educational / R-0.49-MI / R-0.49-M / help / base / exists < prev    next >
Encoding:
Text File  |  1997-04-23  |  1.2 KB  |  40 lines

  1.     
  2.     _I_s _a _V_a_r_i_a_b_l_e _D_e_f_i_n_e_d?
  3.     
  4.          exists(x, where =NULL, envir=sys.frame(sys.parent()), frame =NULL,
  5.                 mode = "any", inherits = TRUE)
  6.     
  7.     _A_r_g_u_m_e_n_t_s:
  8.     
  9.                x : a variable name (given as a quoted string).
  10.     
  11.     where, envir, frame : an environent to be searched. By
  12.                    default this is the environment where the
  13.                    call to envir takes place.
  14.     
  15.             mode : the type of interest for the object.
  16.     
  17.         inherits : should the enclosing frames of the environ-
  18.                    ment be inspected.
  19.     
  20.     _D_e_s_c_r_i_p_t_i_o_n:
  21.     
  22.          This function looks to see if the name x has a value
  23.          bound to it.  If inherits is TRUE and a value is not
  24.          found for x, then the parent frames of envir are
  25.          searched until the name x is encountered.  If mode is
  26.          specified then only objects of that mode are sought.
  27.          The function returns TRUE if the variable is encoun-
  28.          tered and FALSE if not.
  29.     
  30.     _S_e_e _A_l_s_o:
  31.     
  32.          get.
  33.     
  34.     _E_x_a_m_p_l_e_s:
  35.     
  36.          ##  Define a substitute function if necessary:
  37.          if(!exists("some.fun", mode="function"))
  38.           some.fun <- function(x) { cat("some.fun(x)\n"); x }
  39.     
  40.