expr
but with substitutions made relative to
frame
.
substitute(expr, frame=<<see below>>)
list
; if supplied, it is treated as the frame in which
the substitution is done.
More commonly, it is omitted and the local frame of the function calling
substitute
is used.
expr
, with any names occurring in
expr
replaced by the corresponding component of
frame
.
expr
is returned as a parsed, but unevaluated
object.
In this case the result is equivalent to
expression(expr)[[1]]
If the name was a formal argument to the function calling
substitute
,
then the expression for that argument will be substituted-either
the actual or the default expression.
This substitution is unaffected by whether the argument has been evaluated
yet.
Any other names occurring in
frame
will also be substituted with their
local assigned values.
Names that are not found in
frame
will be left alone.
# argument x as a character string label label <- deparse(substitute(x)) # x2 in f2 is the x value in f1 f1 <- function(x, ...) { f2 <- function(x2=substitute(x, sys.nframe() - 1), ...) ... } # in the following case, x in the f2 definition will be looked for # in the session frame and on the search list only f1 <- function(x, ...) { f2 <- function(x2=x, ...) ... }