getAnywhere
Search Packages, Namespaces, and S3 Methods

### Description

Searches attached packages, loaded namespaces, and S3 methods for a given name.

### Usage

    getAnywhere(x)
    argsAnywhere(x)
    ## S3 method for class 'getAnywhere':
    x[i]
    ## S3 method for class 'getAnywhere':
    print(x, ...)

### Arguments

x | In getAnywhere or argsAnywhere, a character string representing the object to be retrieved. If it is not a string, then the unevaluated argument expression is converted to a character string. In the S3 methods for "[" or print, x is an object of class "getAnywhere".
i | a single integer or an integer vector giving the indices of the elements to extract.

... | other arguments passed to the print method. Reserved for future use.

### Details

- getAnywhere searches the attached packages, loaded namespaces, and S3 methods for objects stored with a given name, and then returns an object collecting this information. Printing this object gives a summary of this information, which is useful for understanding where it is defined. [.getAnywhere is useful for selecting a single definition if multiple ones were found.
- argsAnywhere is useful for examining the function arguments for a given function name. argsAnywhere calls getAnywhere, and then calls args on the resulting objects.

Value

getAnywhere | returns a list object of class "getAnywhere" with the following components:
| name | The string name given by x.
| objs | A list of found objects with the name x
| where | A string vector giving location information of the found objects in objs.
| visible | A logical vector specifying whether the found objects are exported from the package or name space.
| dups | A logical vector specifying which of the found objects are identical to an earlier one in the objs list. For found objects that are functions, functions with the same body but different environments are considered to be different (in TERR, but not in R).
argsAnywhere | returns a single value (as returned by the args function), or a list of such values if there are multiple found objects. If no objects are found, it returns NULL.

[.getAnywhere | returns the i-th element from the objs component if i is given as a single number, or a list extracting the indices i from objs if it is not a single number.

print.getAnywhere | returns x itself invisibly.

See Also
get, find, getS3method, loadedNamespaces, exist, args
Examples

    ## exported in package:base, also in namespace, and S3 method
    (res <- getAnywhere("print.default") )
    res$visible  # TRUE FALSE FALSE
    res$dups  # FALSE TRUE TRUE
    res[1] # extract the 1st object only
    res[2:3] # extract the 2nd and 3rd objects
    ## not exported, in namespace and S3 method only
    getAnywhere("print.raster")
    ## if x is not a string, the unevaluated argument is converted to a string
    getAnywhere(print.default)
    ## finds both functions and regular variables
    factor <- factor(1:6)
    getAnywhere("factor")
    ## print function args
    argsAnywhere("print.default")

Package utils version 6.1.5-18
Package Index