The R Project SVN R

Rev

Rev 61168 | Rev 88581 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/base/man/missing.Rd
2
% Part of the R package, http://www.R-project.org
59039 ripley 3
% Copyright 1995-2009 R Core Team
42333 ripley 4
% Distributed under GPL 2 or later
5
 
2 r 6
\name{missing}
56186 murdoch 7
\alias{missing}
2 r 8
\title{Does a Formal Argument have a Value?}
15876 pd 9
\usage{
10
missing(x)
11
}
2 r 12
\description{
13
\code{missing} can be used to test whether a value was specified
14
as an argument to a function.
15
}
15518 ripley 16
\arguments{
17
  \item{x}{a formal argument.}
18
}
15876 pd 19
\details{
20
  \code{missing(x)} is only reliable if \code{x} has not been altered
21
  since entering the function: in particular it will \emph{always}
61433 ripley 22
  be false after \code{x <- match.arg(x)}.
23
 
50263 ripley 24
  The example shows how a plotting function can be written to work with
25
  either a pair of vectors giving x and y coordinates of points to be
26
  plotted or a single vector giving y values to be plotted against their
27
  indices.
17635 luke 28
 
29
  Currently \code{missing} can only be used in the immediate body of
30
  the function that defines the argument, not in the body of a nested
31
  function or a \code{local} call.  This may change in the future.
61433 ripley 32
 
51321 ripley 33
  This is a \sQuote{special} \link{primitive} function: it must not
34
  evaluate its argument.
15876 pd 35
}
24300 ripley 36
\references{
37
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
38
  \emph{The New S Language}.
47262 ripley 39
  Wadsworth & Brooks/Cole.
15876 pd 40
 
24300 ripley 41
  Chambers, J. M. (1998)
55555 ripley 42
  \emph{Programming with Data.  A Guide to the S Language}.
24300 ripley 43
  Springer.
44
}
15876 pd 45
\seealso{
46
  \code{\link{substitute}} for argument expression;
42961 ripley 47
  \code{\link{NA}} for missing values in data.
15876 pd 48
}
2 r 49
\examples{
61168 ripley 50
myplot <- function(x, y) {
2 r 51
                if(missing(y)) {
52
                        y <- x
53
                        x <- 1:length(y)
54
                }
61168 ripley 55
                plot(x, y)
2 r 56
        }
57
}
286 maechler 58
\keyword{programming}