From ggrothendieck at gmail.com  Wed Oct 25 18:28:13 2006
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Wed, 25 Oct 2006 12:28:13 -0400
Subject: [Rd] as.missing
In-Reply-To: <453E462C.6050103@bank-banque-canada.ca>
References: <453E462C.6050103@bank-banque-canada.ca>
Message-ID: <971536df0610250928q615c2e4dl950e8f576c492789@mail.gmail.com>

You can do it like this:

> as.missing <- force
> g <- function(x = as.missing()) missing(x)
> g(3)
[1] FALSE
> g()
[1] TRUE

On 10/24/06, Paul Gilbert <pgilbert at bank-banque-canada.ca> wrote:
> (I'm not sure if this is a request for a feature, or another instance
> where a feature has eluded me for many years.)
>
> Often I have a function which calls other functions, and may often use
> the default arguments to those functions, but needs the capability to
> pass along non-default choices. I usually do this with some variation on
>
> foo <- function(x, foo2Args=NULL or a list(foo2defaults),
>                    foo3Args=NULL or a list(foo3defaults))
>
> and then have logic to check for NULL, or use the list in combination
> with do.call.  It is also possible to do this with ..., but it always
> seems a bit dangerous passing all the unnamed arguments along to all the
> functions being called, especially when I always seem to be calling
> functions that have similar arguments (maxit, eps, start, frequency, etc).
>
> It is a situation I have learned to live with, but one of my
> co-maintainers just pointed out to me that there should be a good way to
> do this in R.  Perhaps there is something else I have missed all these
> years?  Is there a way to do this cleanly? It would be nice to have
> something like
>
> foo <- function(x, foo2Args=as.missing(),  foo3Args=as.missing())
>
> then the call to foo2 and foo3 could specify  foo2Args and foo3Args, but
> these would get treated as if they were missing, unless they are given
> other values.
>
> Paul Gilbert
> ====================================================================================
>
> La version fran?aise suit le texte anglais.
>
> ------------------------------------------------------------------------------------
>
> This email may contain privileged and/or confidential inform...{{dropped}}
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>




[Rd] as.missing
Gabor Grothendieck