Movatterモバイル変換


[0]ホーム

URL:


rdrr.io

ls: List Objects

lsR Documentation

List Objects

Description

ls andobjects return a vector of character stringsgiving the names of the objects in the specified environment. Wheninvoked with no argument at the top level prompt,ls shows whatdata sets and functions a user has defined. When invoked with noargument inside a function,ls returns the names of thefunction's local variables: this is useful in conjunction withbrowser.

Usage

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)

Arguments

name

which environment to use in listing the available objects.Defaults to thecurrent environment. Although calledname for back compatibility, in fact this argument canspecify the environment in any form; see the ‘Details’ section.

pos

an alternative argument toname for specifying theenvironment as a position in the search list. Mostly there forback compatibility.

envir

an alternative argument toname for specifying theenvironment. Mostly there for back compatibility.

all.names

a logical value. IfTRUE, allobject names are returned. IfFALSE, names which begin with a. are omitted.

pattern

an optional regular expression. Only namesmatchingpattern are returned.glob2rx can beused to convert wildcard patterns to regular expressions.

sorted

logical indicating if the resultingcharacter should be sorted alphabetically. Note thatthis is part ofls() may take most of the time.

Details

Thename argument can specify the environment from whichobject names are taken in one of several forms:as an integer (the position in thesearch list); asthe character string name of an element in the search list; or as anexplicitenvironment (including usingsys.frame to access the currently active function calls).By default, the environment of the call tols orobjectsis used. Thepos andenvir arguments are an alternativeway to specify an environment, but are primarily there for backcompatibility.

Note that theorder of strings forsorted = TRUE islocale dependent, seeSys.getlocale. Ifsorted = FALSE the order is arbitrary, depending if the environment ishashed, the order of insertion of objects, ....

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language.Wadsworth & Brooks/Cole.

See Also

glob2rx for converting wildcard patterns to regularexpressions.

ls.str for a long listing based onstr.apropos (orfind)for finding objects in the whole search path;grep for more details on ‘regular expressions’;class,methods, etc., forobject-oriented programming.

Examples

.Ob <- 1ls(pattern = "O")ls(pattern= "O", all.names = TRUE)    # also shows ".[foo]"# shows an empty list because inside myfunc no variables are definedmyfunc <- function() {ls()}myfunc()# define a local variable inside myfuncmyfunc <- function() {y <- 1; ls()}myfunc()                # shows "y"

What can we improve?

R Package Documentation

Browse R Packages

We want your feedback!

Note that we can't provide technical support on individual packages. You should contact the package authors for that.

 
Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, readEmbedding Snippets.

Close

[8]ページ先頭

©2009-2026 Movatter.jp