environment_of.Rd
Get the environment of an object
environment_of(envir)
An R object.
A non-empty character string.
Returns an environment
, if envir
is
an environment, a function, or a formula. In all other cases, NULL is
returned.
## An environment
environment_of(globalenv()) ## <environment: R_GlobalEnv>
#> <environment: R_GlobalEnv>
## A primitive function (always in the 'base' namespace)
environment_of(abs) ## <environment: namespace:base>
#> <environment: namespace:base>
## A package function
environment_of(mean) ## <environment: namespace:base>
#> <environment: namespace:base>
## Another package function
environment_of(stats::median) ## <environment: namespace:stats>
#> <environment: namespace:stats>
## A formula
environment_of(y ~ x) ## <environment: R_GlobalEnv>
#> <environment: 0x55f41581d298>
## A non-function object
environment_of(pi) ## NULL
#> NULL