?sys.parent  (and friends)

-- Bert


On Thu, Sep 5, 2013 at 4:37 PM, ivo welch <ivo.welch@anderson.ucla.edu>wrote:

> quick question.  how do I search up the calling environments until I find a
> variable?
>
> > x=function() { m=22; y() }
> > y=function() { z() }
> > z=function() { mget("m", inherits=TRUE, ifnotfound="m not found") }
> > x()
> $m
> [1] "m not found"
>
> from the perspective of z(), function x is not an enclosing environment.
>  do I write a while loop to look back, or is there a standard R function
> that searches all calling environments until it finds one that works?
>
> regards,
>
> /iaw
> ----
> Ivo Welch (ivo.welch@gmail.com)
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

	[[alternative HTML version deleted]]

