[R] Assignment of structures on a given environment
rita at liacc.up.pt
Tue Oct 16 16:02:55 CEST 2001
In order to avoid deep copies by passing large arguments to functions or
returning values, I'm trying to do the assignment of variables in a
given environment. The problem is when I try to assign a structure: a
list for example.
If I have:
ind <- c("a","b")
my idea is doing something like
l <- alist()
l[ind] <- as.list(c(20,40))
in a given environment.
ref <- new.env()
If I do
it creates me a new variable in the ref environment named "l$a"
So, I did:
eval(l <- alist(), env=ref)
but this creates the l list both on the current and on the ref
The alternative solution that I found out was:
evalq(ind <-c("a","b"), env=ref)
evalq(l[ind] <- as.list(c(20,40)), env=ref)
I would like to know if there is another possible solution, instead of
doing these 'evalqs' along the program code.
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help