Actual Arguments

Usage

substitute(expr, env=NULL)
quote(expr, env=NULL)

Description

substitute returns the expression which was typed as the value of a formal argument. quote is a synonym useful to lisp programmers.

Details

The typical use of this is to create informative labels for data sets and plots. The myplot example below shows a simple use of this facility. It uses the functions deparse and substitute to create labels for a plot which are character string versions of the actual arguments to the function myplot.

See Also

missing for argument ``missingness''.

Examples

substitute(expression(a + b), list(a = 1))#> expression(1 + b)

myplot <- function(x, y)
        plot(x, y, xlab=deparse(substitute(x)),
                ylab=deparse(substitute(y)))

## Simple examples about lazy evaluation, etc:

f1 <- function(x, y = x)             { x <- x + 1; y }
s1 <- function(x, y = substitute(x)) { x <- x + 1; y }
s2 <- function(x, y) { if(missing(y)) y <- substitute(x); x <- x + 1; y }
a <- 10
f1(a)# 11
s1(a)# 11
s2(a)# a
typeof(s2(a))# "symbol"


[Package Contents]