ls                   package: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 environment. 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 = as.environment(pos),
        all.names = FALSE, pattern)
     objects(name, pos= -1, envir = as.environment(pos),
             all.names = FALSE, pattern)

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

    name: which environment to use in listing the available objects.
          Defaults to the _current_ environment.  Although called
          'name' for back compatibility, in fact this argument can
          specify the environment in any form; see the details section.

     pos: An alternative  argument to 'name' for specifying the
          environment as a position in the search list.  Mostly there
          for back compatibility.

   envir: an alternative  argument to 'name' for specifying the
          environment evaluation environment. Mostly there for back
          compatibility.

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. Only names matching 'pattern'
          are returned.

_D_e_t_a_i_l_s:

     The 'name' argument can specify the  environment from which object
     names are taken in one of several forms: as an integer (the
     position in the 'search' list); as the character string name of an
     element in the search list; or as an explicit 'environment'
     (including using 'sys.frame' to access the currently active
     function calls). By default, the environment of the call to 'ls'
     or 'objects' is used. The 'pos' and 'envir' arguments are an
     alternative way to specify an environment, but are primarily there
     for back compatibility.

_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:

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

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

     .Ob <- 1
     ls(pat="O")
     ls(pat="O", all = TRUE)    # 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"

