Skip to content
Prev 189296 / 398498 Next

A question regarding R scoping

Hi,

Perhaps I have to rephrase a bit my question. If we have the following:

i = 10
f1 = function(i){
i <<- 1
}

after calling f1, the value of i becomes 1. Now, suppose that f1 is called in another function f2, and i is initialized in f2 as well, i.e:

f2 = function(n){
i = n
f1(i)
}

The intention is, after executing f2, i=1 (not i=n).
--- On Thu, 8/6/09, Steve Lianoglou <mailinglist.honeypot at gmail.com> wrote: