whereis: Which environment/package(s) is/are a function located in the...

View source: R/whereis.R

whereisR Documentation

Which environment/package(s) is/are a function located in the search() path

Description

Which environment/package(s) is/are a function located in the search() path

Usage

whereis(x, env = parent.frame(), mode = c("function", "any"))

Arguments

x

function or function name to search.

env

environment to search, if the function x is not found in this environment, the parent environment is further searched until the top environment, i.e. empty environment (emptyenv()) or R_EmptyEnv.

mode

either "function" or "any", if mode = "function" (default), considering x is only a function object.

Value

environment where the function/object x is found. If x is not found, NULL is returned. If multiple environments are found, the first environment is the default place to get the value of x.

Examples

## Not run: 
detachPackages("Matrix")
whereis("print")
whereis(print)

# Matrix::print is the default print
library(Matrix)
whereis("print")
identical(print, Matrix::print)
identical(print, base::print)

print = function() print()
whereis("print")

# Search any object
whereis(.Options, mode = "any")

## End(Not run)

paodan/funcTools documentation built on April 1, 2024, 12:01 a.m.