[R] environment
Romain Francois
francoisromain at free.fr
Wed Apr 26 09:49:08 CEST 2006
Hi,
Consider the code :
g <- function(){
print(.x)
.x <- 3
}
f <- function(){
environment(g) <- environment()
.x <- 2
g()
.x
}
> f()
[1] 2
[1] 2
I would like f() to return 3. How can I do that ? Am I completely out of
place ?
Doing that, I want to avoid to pass .x as a parameter in f, because in
real life .x is pretty big and g() is called over and over in a loop.
Thanks
Romain
--
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
mixmod 1.7 is released : http://www-math.univ-fcomte.fr/mixmod/index.php
+---------------------------------------------------------------+
| Romain FRANCOIS - http://francoisromain.free.fr |
| Doctorant INRIA Futurs / EDF |
+---------------------------------------------------------------+
More information about the R-help
mailing list