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

From: Bill Dunlap <>
Date: Thu 14 Sep 2006 - 21:08:23 GMT

On Thu, 14 Sep 2006, Robert Gentleman wrote:

> > > 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
> yes, but the logic seems to be broken. In Seth's case there seems to be
> no way to use substitute to globally change an argument and all
> instances throughout a function, which seems like a task that would be
> useful.

> even here, I would have expected all instances of a to change, not some

In Splus, substitute changes all "name" objects with the values given by the names on the list given as its second argument. In Splus the argument name in the formals list is not of class "name" - it is of class "character". Hence it is not substituted. I agree it would be handy if it were substituted.

In R I'm not sure what class/mode the argument name in the formals list has. The formals list is a "pairlist" and the argument names are th names of the pairlist. What internal class/mode do they have?

However, substitute() in R does not appear to go into formal arguments of a function at all.

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 07:11:20 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 - 23:30:15 GMT.

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