Skip to content
Prev 67833 / 398506 Next

Define "local" function

Peter Dalgaard wrote:
Why worry about where the line occurs?  In R, there is little 
distinction between functions and data, so you could say that the 
function definition isn't done until you're finished modifying it.
A more likely thing to want to do is to see the search path only after 
the global environment, which you can do with

environment(f) <- as.environment(2)

(the 2 says to use the 2nd environment on the search path).  This might 
not be perfect, since you can use attach() to modify the search path, 
but it would likely be good enough to flush out simple programming bugs.

Duncan Murdoch