Skip to content
Prev 332729 / 398506 Next

Function does not see variables outside the function

Dear Zhong-Yuan Zhang,

R is lexically scoped. Pretending that you're using a different programming
language is probably a bad idea. 

The findGlobals() function in the codetools package, which is part of the
standard R distribution, can help you locate references to global variables
(and functions) in a function. For example,
[1] "a" "g"
[1] "{"  "<-" "g"
[1] "g"

I hope this helps,
 John