Re: [R] NULL or NA for missing function arguments?

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon 16 Oct 2006 - 18:01:32 GMT

On 10/16/06, Hans-Peter <gchappi@gmail.com> wrote:
> 2006/10/16, Duncan Murdoch <murdoch@stats.uwo.ca>:
> > As Gabor said, the third way is to give no default, but test missing()
> > in the code.
>
> I forgot this one, thank you. In my case it is probably not suited as
> I just pass the arguments to a C (Pascal) function and do the checking
> there.

The R interface need not be identical to the C or Pascal interface. Its pretty easy to convert making use of the fact that a nonexistent else leg returns NULL:

f <- function(x) { x <- if (!missing(x)) x; x } f() # NULL



R-help@stat.math.ethz.ch 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. Received on Tue Oct 17 04:08:01 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 16 Oct 2006 - 18:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.