get
Search for a Named Object

### Description

Searches for a named object and returns it if it is found. mget is used to get multiple values from an environment.

### Usage

    get(x, pos = -1, envir = as.environment(pos), mode = "any",
        inherits = TRUE)
    mget(x, envir = as.environment(-1), mode = "any", ifnotfound,
         inherits = FALSE)

### Arguments

x | a character string giving the name of the object. Must be non-empty string.
pos | an integer, a character string, or an environment specifying in which environment to find the object.
envir | an environment object. An alternative way to specify in which environment to find the object. as.environment(-1) means the environment from which get or mget is called.
mode | a character string giving the mode wanted for the object. The default, "any", means that any mode is acceptable.
inherits | a logical flag. If inherits=TRUE (the default), the parent environment and all further ancestors are searched. If inherits=FALSE, only the specified environment is searched.
ifnotfound | a list or atomic vector with the same length as x or with length 1. In mget, if some element of x cannot be found, the corresponding value of ifnotfound will be returned instead. If that element is a function, it will be called with the name that could not be found as its argument and the return value of that call will be returned. If the ifnotfound argument is not given, and an element of x cannot be found, an error is generated.

### Details

If both pos and envir are omitted, the search is done as if name were an ordinary name in an expression. That is, the search occurs first in the local environment, and then it proceeds searching parent environments.
In function mget, mode should be of the same length with x, or length 1.
Value

get | returns the object. Failure to find the object causes an error.
mget | returns a list of objects, the same length as x, with names taken from x

See Also
assign, remove, ls, attach, getFunction, existsFunction, getMethod, existsMethod, objects.
Examples

    get("[[") # get or print an object of a non-standard name, same as `[[`
    env1 <- new.env()
    env1$One <- 1
    mget(c("One", "Two"), env1, ifnotfound = "<nil>")

Package base version 6.1.5-18
Package Index