EVOLUTION-MANAGER
Edit File: missing.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Does a Formal Argument have a Value?</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for missing {base}"><tr><td>missing {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Does a Formal Argument have a Value?</h2> <h3>Description</h3> <p><code>missing</code> can be used to test whether a value was specified as an argument to a function. </p> <h3>Usage</h3> <pre> missing(x) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a formal argument.</p> </td></tr> </table> <h3>Details</h3> <p><code>missing(x)</code> is only reliable if <code>x</code> has not been altered since entering the function: in particular it will <em>always</em> be false after <code>x <- match.arg(x)</code>. </p> <p>The example shows how a plotting function can be written to work with either a pair of vectors giving x and y coordinates of points to be plotted or a single vector giving y values to be plotted against their indices. </p> <p>Currently <code>missing</code> can only be used in the immediate body of the function that defines the argument, not in the body of a nested function or a <code>local</code> call. This may change in the future. </p> <p>This is a ‘special’ <a href="Primitive.html">primitive</a> function: it must not evaluate its argument. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <p>Chambers, J. M. (1998) <em>Programming with Data. A Guide to the S Language</em>. Springer. </p> <h3>See Also</h3> <p><code><a href="substitute.html">substitute</a></code> for argument expression; <code><a href="NA.html">NA</a></code> for missing values in data. </p> <h3>Examples</h3> <pre> myplot <- function(x, y) { if(missing(y)) { y <- x x <- 1:length(y) } plot(x, y) } </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>