From bill at insightful.com  Thu Sep 14 23:08:23 2006
From: bill at insightful.com (Bill Dunlap)
Date: Thu, 14 Sep 2006 14:08:23 -0700 (PDT)
Subject: [Rd] Question about substitute() and function def
In-Reply-To: <4509B22D.1050604@fhcrc.org>
References: <m2d59y8e7o.fsf@ziti.fhcrc.org> <4509AFA4.6010203@stats.uwo.ca>
	<4509B22D.1050604@fhcrc.org>
Message-ID: <Pine.GSO.4.56.0609141355250.2611@durian.statsci.com>

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
360-428-8146

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."




[Rd] Question about substitute() and function def
Bill Dunlap