Thank you very much for your suggestion.
f <- function(a,b,c) {
names <- ls(environment()) # get all the names
result <- list()
for (n in names) {
if (!do.call(missing, list(as.name(n))))
result[n] <- get(n)
}
result
}
I have already figured out a very similar solution using for/eval that
basically does the same. I was hoping that I would somehow could get
around the ugly loop using a more elegant approach. The loop should have
a negative impact on performance since my function is using a lot of
parameters. I was hoping, that there was some flag to tell the as.list
function to ignore non existing objects. If that is not possible I will
have to accept this.
If you put the ls() call later, you'll pick up other local variables
(names, result, n) as well.
Of course. That is why I call it at the very first line of my function.
Thanks again!
Heiko Neuhaus
______________________________________________
[email protected] 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.