Re: [R] Remembering a value in multiple calls of a function

2009-07-17 Thread Saptarshi Guha
Thanks to all for the helpful explanation. Regards Saptarshi On Fri, Jul 17, 2009 at 12:42 AM, wrote: > 'startgiven' is in the environment of your function 'incr' (which is what > your function 'a' becomes).  It might be more transparent to define your > function with an enclosing local environ

Re: [R] Remembering a value in multiple calls of a function

2009-07-17 Thread Bill.Venables
'startgiven' is in the environment of your function 'incr' (which is what your function 'a' becomes). It might be more transparent to define your function with an enclosing local environment explicitly, for example: > b <- local({ + startgiven <- 0 + function(n) { + if(!missing(n)) { +

Re: [R] Remembering a value in multiple calls of a function

2009-07-17 Thread Douglas Bates
On Fri, Jul 17, 2009 at 9:15 AM, Saptarshi Guha wrote: > Hello, > I tried this pseudo-generator style experiment (see below). The "<<-" > operator assigns to in the calling environment which would be the > environment of  "getN". Yes. > Yet when the function incr is returned, isn't this environme