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

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

On 10/16/06, Hans-Peter <> wrote:
> 2006/10/16, Duncan Murdoch <>:
> > 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 mailing list PLEASE do read the posting guide 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 Please read the posting guide before posting to the list.