[R] how modify object in parent.env

Vadim Ogranovich vograno at evafunds.com
Wed Mar 9 00:36:14 CET 2005


Hi,
 
Is it possible to modify an object in the parent.env (as opposed to
re-bind)? Here is what I tried:
 
> x = 1:3
# try to modify the first element of x from within a new environment
> local(get("x", parent.env(environment()))[1] <- NA)
Error in eval(expr, envir, enclos) : Target of assignment expands to
non-language object

# On the other hand retrieval works just fine
> local(get("x", parent.env(environment()))[1])
[1] 1

Thanks,
Vadim




More information about the R-help mailing list