R/enclosing.R

Defines functions enclosing_env

Documented in enclosing_env

#' Find the environment that encloses of a function.
#'
#' This is a wrapper around \code{\link{environment}} with a
#' consistent syntax.
#'
#' @param f The name of a function.
#' @export
#' @examples
#' enclosing_env("plot")
#' enclosing_env("t.test")
enclosing_env <- function(f) {
  f <- match.fun(f)
  environment(f)
}

Try the pryr package in your browser

Any scripts or data that you put into this service are public.

pryr documentation built on Jan. 18, 2023, 1:08 a.m.