From ggrothendieck at gmail.com  Tue Aug 23 13:16:02 2005
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Tue, 23 Aug 2005 07:16:02 -0400
Subject: [Rd] do.call(): no need for quote {was .. Questions about
	calls..}
In-Reply-To: <17162.60051.935766.508861@stat.math.ethz.ch>
References: <430A4629.8010506@univie.ac.at>
	<40e66e0b05082214525e2140e8@mail.gmail.com>
	<430A556E.4080203@univie.ac.at>
	<971536df050822155550243049@mail.gmail.com>
	<17162.60051.935766.508861@stat.math.ethz.ch>
Message-ID: <971536df05082304163df135e@mail.gmail.com>

On 8/23/05, Martin Maechler <maechler at stat.math.ethz.ch> wrote:
> >>>>> "Gabor" == Gabor Grothendieck <ggrothendieck at gmail.com>
> >>>>>     on Mon, 22 Aug 2005 18:55:38 -0400 writes:
> 
>   ..................
> 
>    Gabor> Try do.call like this:
> 
>    Gabor> ff <- x ~ g*h
>    Gabor> do.call("substitute", list(ff, list(x = as.name("weight"))))
> 
> Just a small remark: For all those who -- like me -- have found
> it  ``unpleasant'' to have to quote the first argument of do.call():
> You don't have to any longer since the NEWS of R 2.1.0 contains
> 
>    o   do.call() now takes either a function or a character string as
>        its first argument.  The supplied arguments can optionally be
>        quoted.
> 
> So the above could be
> 
>   do.call(substitute, list(ff, list(x = as.name("weight"))))

I have used that form but went back to the character form
when I noticed the entire text of the function appearing
in tracebacks, which I found to be a nuisance, particularly
for functions with large bodies:

> f <- function(x) { stop() }
> do.call(f, list(3))
Error in function (x)  : 
> traceback()
3: stop()
2: function (x) 
   {
       stop()
   }(3)
1: do.call(f, list(3))

Of course, in the case of substitute the body is only one line.



[Rd] do.call(): no need for quote {was .. Questions about calls..}
Gabor Grothendieck