blue sky
2010-Feb-12 15:41 UTC
[R] Is there a way to figure out what nonlocal variables and functions have been used in a function?
x=10 f=function() {print('in f')} g=function() {f(); print(x)} g() Suppose I have the above code, I want to know what functions and variables have been used in the function g (in this case, f and x). Is there a function to do so?
Sharpie
2010-Feb-12 19:36 UTC
[R] Is there a way to figure out what nonlocal variables and functions have been used in a function?
blue sky wrote:> > x=10 > f=function() {print('in f')} > g=function() {f(); print(x)} > g() > > Suppose I have the above code, I want to know what functions and > variables have been used in the function g (in this case, f and x). Is > there a function to do so? > >Try findGlobals() from the codetools package: require( codetools ) findGlobals( g ) [1] "{" "f" "print" "x" -Charlie -- View this message in context: http://n4.nabble.com/Is-there-a-way-to-figure-out-what-nonlocal-variables-and-functions-have-been-used-in-a-function-tp1478673p1488760.html Sent from the R help mailing list archive at Nabble.com.