On Tue, Oct 13, 2015 at 4:43 PM, Hadley Wickham <h.wick...@gmail.com> wrote:
> Seems easy enough to write yourself:
>
> where <- function(x, env = parent.frame()) {
>     if (identical(env, emptyenv()))
>         return(NULL)
>     if (exists(x, envir = env, inherits = FALSE))
>         return(env)
>     where(x, parent.env(env))
> }
>
> sample2 <- base::sample
> where("sample2")
> #> <environment: 0x1154d3c28>

And that returns a random environment because I ran it with
reprex::reprex().  In interactive use it will return <environment:
R_GlobalEnv>

Hadley

-- 
http://had.co.nz/

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to