[R] NULL or NA for missing function arguments?
Gabor Grothendieck
ggrothendieck at gmail.com
Mon Oct 16 20:01:32 CEST 2006
On 10/16/06, Hans-Peter <gchappi at gmail.com> wrote:
> 2006/10/16, Duncan Murdoch <murdoch at 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
More information about the R-help
mailing list