which.package: Function to tell you which package a function came from.

Description Usage Arguments Value Note Author(s) Examples

Description

Given a function, identify which package(s) it was defined in. Most packages now have namespaces, so functions can either be exported, or not. If your function is exported in a namespace, then no problems. If your function is not exported (usually hidden functions starting with ‘.’, eg: .gsea.get.classes.index.html from metaGSEA, then there's no facility in native R to determine this (AFAICT). By searching through a collection of source code, you may find the file that contains the function, and thus which package its from.

Usage

1
2
  which.package(func, unique = FALSE,
    src.root = getOption("src.root"), verbose = FALSE)

Arguments

func

either the quoted function name (eg “plot”), or the function's name (eg plot). Can be a character vector of multiple function's names.

unique

logical: if TRUE, only return the first result (some functions are defined in multiple packages), if FALSE and > 1 instances are found, then all will be returned

src.root

the root folder containing all your R packages under development.

verbose

logical

Value

a vector of package names, 1 per function in func

Note

If your function is hidden (ie, starts with a dot), then you must use its quoted name when passing to func=".my.hidden.function", otherwise doing this: func=.my.hidden.function, will cause the R interpreter to complain that it can't find .my.hidden.function.

Author(s)

Mark Cowley

Examples

1
2
3
4
## Not run: 
which.package(plot)

## End(Not run)

drmjc/updateR documentation built on May 15, 2019, 2:41 p.m.