Dear list,

I have a problem with nested functions and I don't manage to get it
solved. I know I should be looking in environments, and I have tried a
lot, but it keeps on erroring. 
An easy version of the problem is as follows:



innerfunction<-function()
{
    print(paste(a, " from inner function"))
    print(paste(b, " from inner function"))
    setwd(wd)
}


middlefunction<-function()
{
    b="b"
    print(paste(b, " from middle function"))
    innerfunction()
}


outerfunction<-function()
{
    a="a"
    print(paste(a," from outer function"))
    middlefunction()
}

outerfunction()



Here, R will tell me that the inner function has no clue what a or b is.
So what I want, is the inner function to recognize a and b.
Any suggestions?

Many thanks!
Rik




-- 
________________________________________________

Rik Verdonck



Research group of Molecular Developmental Physiology and Signal
Transduction
KULeuven, Faculty of Science
Naamsestraat 59,  Bus 02465
B-3000 Leuven,Belgium
Tel. +32 16 32 39 65
Fax +32 16 32 39 02

http://bio.kuleuven.be/df/JV/index2.htm
rik.verdo...@bio.kuleuven.be





      Please consider the environment before printing this e-mail

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to