Re: [R] Lazy evaluation in function call

2010-05-05 Thread Thorn
Bert Gunter gunter.berton at gene.com writes: Inline below. -- No. f - function(x, y = x)x+y ## lazy evaluation enables this f(2) [1] 4 f(2,3) [1] 5 Ok, obviously I was not very precise about what I'd like to do. Sorry. I'm aware of this functionality. But I'd like to use the

Re: [R] Lazy evaluation in function call

2010-05-05 Thread Duncan Murdoch
Thorn wrote: Bert Gunter gunter.berton at gene.com writes: Inline below. -- No. f - function(x, y = x)x+y ## lazy evaluation enables this f(2) [1] 4 f(2,3) [1] 5 Ok, obviously I was not very precise about what I'd like to do. Sorry. I'm

[R] Lazy evaluation in function call

2010-05-04 Thread Thorn
Hi everybody, how is it possible to refer to an argument passed to a function in the function call? What I like to do, is something like f - function(x,y) x+y f(2, x) # should give 4 The problem is of course that x is only known inside the function. Of course I could specify something like

Re: [R] Lazy evaluation in function call

2010-05-04 Thread Joris Meys
I think you'll have to code it a bit different. I'd do : f - function(x,y){ if(missing(y)) y -x x+y } f(2) [1] 4 f(2,3) [1] 5 On Tue, May 4, 2010 at 4:26 PM, Thorn thorn.tha...@rdls.nestle.com wrote: Hi everybody, how is it possible to refer to an argument passed to a function in the

Re: [R] Lazy evaluation in function call

2010-05-04 Thread Bert Gunter
evaluation in function call I think you'll have to code it a bit different. I'd do : f - function(x,y){ if(missing(y)) y -x x+y } f(2) [1] 4 f(2,3) [1] 5 On Tue, May 4, 2010 at 4:26 PM, Thorn thorn.tha...@rdls.nestle.com wrote: Hi everybody, how is it possible to refer to an argument passed