I'm still getting used to R's scoping. I've run into the following situation

value=0
thefunction <- function() print( value )
somefunction <- function() { value=99; thefunction() }
somefunction()

now, I understand that somefunction() returns 0 because thefunction() was
defined with value=0 in its parent envrionment, it dosent look at all in the
environment of somefunction. My question is can I re-scope thefunction in
the somefunction environment?? (So that somefunction() returns 99). I've
tried various uses of eval() and assign() with their keywords in the
definition of somefunction and have had no luck at all.

I do see that i could define thefunction in some external file and source it
inside somefunction, but that seems clumsy.

thanks!!

James

        [[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.

Reply via email to