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)
}
hadley/pryr documentation built on Jan. 5, 2024, 10:38 a.m.