Rev 81245 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/base/man/expression.Rd% Part of the R package, https://www.R-project.org% Copyright 1995-2021 R Core Team% Distributed under GPL 2 or later\name{expression}\alias{expression}\alias{is.expression}\alias{as.expression}\alias{as.expression.default}\title{Unevaluated Expressions}\description{Creates or tests for objects of mode and class \code{"expression"}.}\usage{expression(\dots)is.expression(x)as.expression(x, \dots)}\arguments{\item{\dots}{\code{expression}: \R objects, typically calls, symbolsor constants.\cr\code{as.expression}: arguments to be passed to methods.}\item{x}{an arbitrary \R object.}}\details{\sQuote{Expression} here is not being used in its colloquial sense,that of mathematical expressions. Those are calls (see\code{\link{call}}) in \R, and an \R expression vector is a list ofcalls, symbols etc, for example as returned by \code{\link{parse}}.As an object of mode \code{"expression"} is a list, it can besubsetted by \code{[}, \code{[[} or \code{$}, the latter two extractingindividual calls etc. The replacement forms of these operators can beused to replace or delete elements.\code{expression} and \code{is.expression} are \link{primitive} functions.\code{expression} is \sQuote{special}: it does not evaluate its arguments.}\value{\code{expression} returns a vector of type \code{"expression"}containing its arguments (unevaluated).\code{is.expression} returns \code{TRUE} if \code{expr} is anexpression object and \code{FALSE} otherwise.\code{as.expression} attempts to coerce its argument into anexpression object. It is generic, and only the default method isdescribed here. (The default method calls\code{as.vector(type = "expression")} and so may dispatch methods for\code{\link{as.vector}}.) \code{NULL}, calls, symbols (see\code{\link{as.symbol}}) and pairlists are returned as the element ofa length-one expression vector. Atomic vectors are placedelement-by-element into an expression vector (without using anynames): \code{\link{list}}s have their type (\code{\link{typeof}})changed to an expression vector(keeping all attributes).Other types are not currently supported.}\references{\bibshow{R:Becker+Chambers+Wilks:1988}}\seealso{\code{\link{call}},\code{\link{eval}},\code{\link{function}}.Further,\code{\link{text}}, \code{\link{legend}}, and \code{\link{plotmath}}for plotting mathematical expressions.}\examples{length(ex1 <- expression(1 + 0:9)) # 1ex1eval(ex1) # 1:10length(ex3 <- expression(u, 2, u + 0:9)) # 3mode(ex3 [3]) # expressionmode(ex3[[3]]) # call## but not all components are 'call's :sapply(ex3, mode ) # name numeric callsapply(ex3, typeof) # symbol double languagerm(ex3)}\keyword{programming}\keyword{dplot}