Re: [R] Lazy evaluation in function call

2010-05-05 Thread Duncan Murdoch
Thorn wrote: Bert Gunter 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 f

Re: [R] Lazy evaluation in function call

2010-05-05 Thread Thorn
Bert Gunter 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 same i

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 wrote: > Hi everybody, > > how is it possible to refer to an ar

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 wrote: > Hi everybody, > > how is it possible to refer to an argument passed to a function in the > function call? What I li