

ls {base}                                    R Documentation

_L_i_s_t _O_b_j_e_c_t_s

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

     `ls' and `objects' return a vector of character strings
     giving the names of the objects in the specified envi-
     ronment.  When invoked with no argument at the top
     level prompt, `ls' shows what data sets and functions a
     user has defined.  When invoked with no argument inside
     a function, `ls' returns the names of the functions
     local variables.  This is useful in conjunction with
     `browser'.

_U_s_a_g_e_:

     ls(name, pos= -1, envir=pos.to.env(pos),
            all.names=FALSE, pattern)
     objects(name, pos= -1, envir=pos.to.env(pos),
            all.names=FALSE, pattern)

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

    name: the name of an attached object appearing in the
          vector of names returned by `search'.

     pos: the index of an attached object in the list
          returned by `search'.  Defaults to the current
          environment.

   envir: an evaluation environment.  Defaults to the one
          corresponding to `pos'.

all.names: a logical value.  If `TRUE', all object names are
          returned.  If `FALSE', names which begin with a
          ``.'' are omitted.

 pattern: an optional regular expression, see `grep'.  Only
          names matching `pattern' are returned.

_N_o_t_e_:

     It is possible to compile R so that `grep' and hence
     argument `pattern' and not operational.

_S_e_e _A_l_s_o_:

     `apropos' (or `find') for finding objects in the whole
     search path; `grep' for more details on ``regular
     expressions''; `class', `methods', etc. for object-ori-
     ented programming.

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

     .Ob <- 1
     ls(pat="O")
     ls(pat="O", all = T)    # also shows ".[foo]"

     # shows an empty list because inside myfunc no variables are defined
     myfunc <- function() {ls()}
     myfunc()

     # define a local variable inside myfunc
     myfunc <- function() {y <- 1; ls()}
     myfunc()                # shows "y"

