EVOLUTION-MANAGER
Edit File: ls.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: List Objects</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for ls {base}"><tr><td>ls {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>List Objects</h2> <h3>Description</h3> <p><code>ls</code> and <code>objects</code> 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, <code>ls</code> shows what data sets and functions a user has defined. When invoked with no argument inside a function, <code>ls</code> returns the names of the function's local variables: this is useful in conjunction with <code>browser</code>. </p> <h3>Usage</h3> <pre> ls(name, pos = -1L, envir = as.environment(pos), all.names = FALSE, pattern, sorted = TRUE) objects(name, pos= -1L, envir = as.environment(pos), all.names = FALSE, pattern, sorted = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>name</code></td> <td> <p>which environment to use in listing the available objects. Defaults to the <em>current</em> environment. Although called <code>name</code> for back compatibility, in fact this argument can specify the environment in any form; see the ‘Details’ section.</p> </td></tr> <tr valign="top"><td><code>pos</code></td> <td> <p>an alternative argument to <code>name</code> for specifying the environment as a position in the search list. Mostly there for back compatibility.</p> </td></tr> <tr valign="top"><td><code>envir</code></td> <td> <p>an alternative argument to <code>name</code> for specifying the environment. Mostly there for back compatibility.</p> </td></tr> <tr valign="top"><td><code>all.names</code></td> <td> <p>a logical value. If <code>TRUE</code>, all object names are returned. If <code>FALSE</code>, names which begin with a <span class="samp">.</span> are omitted.</p> </td></tr> <tr valign="top"><td><code>pattern</code></td> <td> <p>an optional <a href="regex.html">regular expression</a>. Only names matching <code>pattern</code> are returned. <code><a href="../../utils/html/glob2rx.html">glob2rx</a></code> can be used to convert wildcard patterns to regular expressions.</p> </td></tr> <tr valign="top"><td><code>sorted</code></td> <td> <p>logical indicating if the resulting <code><a href="character.html">character</a></code> should be sorted alphabetically. Note that this is part of <code>ls()</code> may take most of the time.</p> </td></tr> </table> <h3>Details</h3> <p>The <code>name</code> argument can specify the environment from which object names are taken in one of several forms: as an integer (the position in the <code><a href="search.html">search</a></code> list); as the character string name of an element in the search list; or as an explicit <code><a href="environment.html">environment</a></code> (including using <code><a href="sys.parent.html">sys.frame</a></code> to access the currently active function calls). By default, the environment of the call to <code>ls</code> or <code>objects</code> is used. The <code>pos</code> and <code>envir</code> arguments are an alternative way to specify an environment, but are primarily there for back compatibility. </p> <p>Note that the <em>order</em> of strings for <code>sorted = TRUE</code> is locale dependent, see <code><a href="locales.html">Sys.getlocale</a></code>. If <code>sorted = FALSE</code> the order is arbitrary, depending if the environment is hashed, the order of insertion of objects, .... </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="../../utils/html/glob2rx.html">glob2rx</a></code> for converting wildcard patterns to regular expressions. </p> <p><code><a href="../../utils/html/ls_str.html">ls.str</a></code> for a long listing based on <code><a href="../../utils/html/str.html">str</a></code>. <code><a href="../../utils/html/apropos.html">apropos</a></code> (or <code><a href="../../utils/html/apropos.html">find</a></code>) for finding objects in the whole search path; <code><a href="grep.html">grep</a></code> for more details on ‘regular expressions’; <code><a href="class.html">class</a></code>, <code><a href="../../utils/html/methods.html">methods</a></code>, etc., for object-oriented programming. </p> <h3>Examples</h3> <pre> .Ob <- 1 ls(pattern = "O") ls(pattern= "O", all.names = 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" </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>