Inline below. -- Bert
Bert Gunter Genentech Nonclinical Statistics -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Joris Meys Sent: Tuesday, May 04, 2010 2:52 PM To: Thorn Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Lazy 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 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 -- No. f <- function(x, y = x)x+y ## lazy evaluation enables this > f(2) [1] 4 > f(2,3) [1] 5 -- Bert ______________________________________________ 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.