The R Project SVN R

Rev

Rev 88581 | 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
68948 ripley 2
% Part of the R package, https://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{
88581 hornik 37
  \bibshow{R:Becker+Chambers+Wilks:1988}
15876 pd 38
 
88585 hornik 39
  \bibshow{R:Chambers:1998}
24300 ripley 40
}
15876 pd 41
\seealso{
42
  \code{\link{substitute}} for argument expression;
42961 ripley 43
  \code{\link{NA}} for missing values in data.
15876 pd 44
}
2 r 45
\examples{
61168 ripley 46
myplot <- function(x, y) {
2 r 47
                if(missing(y)) {
48
                        y <- x
49
                        x <- 1:length(y)
50
                }
61168 ripley 51
                plot(x, y)
2 r 52
        }
53
}
286 maechler 54
\keyword{programming}