[R] Problems accessing environment() in function

Heiko Neuhaus webmaster at euros4click.de
Wed May 2 18:59:06 CEST 2012


Thanks a lot for your answer!

>> ------------------------------
>>
>> test1 <- function(a, b, c)
>> {
>> x <- as.list(environment())
>> print ("hi from test1!")
>> test2(a = a, b = b, c = c)
>
> You are rying to pass a, b, c here and hence R tries to insert those
> into the environment of test2 once it is called, you have not passed
> arguments to your test1 call.
>
> Uwe Ligges

I am aware that I am passing non existing arguments here, which is why 
my method of creating a list of the environment "as.list(environment())" 
seems to fail in this case.

What I need is a way to just skip non existing objects when I create my 
list. In my given example I was intending to receive an empty list, 
since no valid arguments were passed to test2().

In other words: I want a list containing all _existing_ variable/value 
combinations and just skip the missing ones.

Thanks again for your time

Best wishes,
Heiko Neuhaus



More information about the R-help mailing list