[Rd] Question about substitute() and function def
Bill Dunlap
bill at insightful.com
Thu Sep 14 23:08:23 CEST 2006
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."
More information about the R-devel
mailing list