Re: [Rd] Question about substitute() and function def

From: Bill Dunlap <>
Date: Thu 14 Sep 2006 - 19:54:34 GMT

On Thu, 14 Sep 2006, Duncan Murdoch wrote:

> I think it's the same reason that this happens:
> > substitute(c( a = 1, b = a), list(a = quote(foo)))
> c(a = 1, b = foo)
> The "a" in function(a) is the name of the arg, it's not the arg itself
> (which is missing). Now a harder question to answer is why this happens:
> > substitute(function(a=a) 1, list(a=quote(foo)))
> function(a = a) 1
> I would have expected to get "function(a = foo) 1".

In Splus you do get what you expected.

   > substitute(function(a=a) 1, list(a=quote(foo)))    function(a = foo)
   > substitute(function(a=func(100))func(a), list(func=quote(myFunction)))    function(a = myFunction(100))

R's substitute does not appear to go into the 'formals' of a function definition
when looking for names to replace.

Bill Dunlap
Insightful Corporation
bill at insightful dot com

 "All statements in this message represent the opinions of the author and do  not necessarily reflect Insightful Corporation policy or position." mailing list Received on Fri Sep 15 05:58:36 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 Thu 14 Sep 2006 - 20:16:58 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.