EVOLUTION-MANAGER
Edit File: na.fail.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: Handle Missing Values in Objects</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 na.fail {stats}"><tr><td>na.fail {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Handle Missing Values in Objects</h2> <h3>Description</h3> <p>These generic functions are useful for dealing with <code><a href="../../base/html/NA.html">NA</a></code>s in e.g., data frames. <code>na.fail</code> returns the object if it does not contain any missing values, and signals an error otherwise. <code>na.omit</code> returns the object with incomplete cases removed. <code>na.pass</code> returns the object unchanged. </p> <h3>Usage</h3> <pre> na.fail(object, ...) na.omit(object, ...) na.exclude(object, ...) na.pass(object, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>object</code></td> <td> <p>an <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> object, typically a data frame</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further arguments special methods could require.</p> </td></tr> </table> <h3>Details</h3> <p>At present these will handle vectors, matrices and data frames comprising vectors and matrices (only). </p> <p>If <code>na.omit</code> removes cases, the row numbers of the cases form the <code>"na.action"</code> attribute of the result, of class <code>"omit"</code>. </p> <p><code>na.exclude</code> differs from <code>na.omit</code> only in the class of the <code>"na.action"</code> attribute of the result, which is <code>"exclude"</code>. This gives different behaviour in functions making use of <code><a href="nafns.html">naresid</a></code> and <code><a href="nafns.html">napredict</a></code>: when <code>na.exclude</code> is used the residuals and predictions are padded to the correct length by inserting <code>NA</code>s for cases omitted by <code>na.exclude</code>. </p> <h3>References</h3> <p>Chambers, J. M. and Hastie, T. J. (1992) <em>Statistical Models in S.</em> Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="na.action.html">na.action</a></code>; <code><a href="../../base/html/options.html">options</a></code> with argument <code>na.action</code> for setting NA actions; and <code><a href="lm.html">lm</a></code> and <code><a href="glm.html">glm</a></code> for functions using these. <code><a href="na.contiguous.html">na.contiguous</a></code> as alternative for time series. </p> <h3>Examples</h3> <pre> DF <- data.frame(x = c(1, 2, 3), y = c(0, 10, NA)) na.omit(DF) m <- as.matrix(DF) na.omit(m) stopifnot(all(na.omit(1:3) == 1:3)) # does not affect objects with no NA's try(na.fail(DF)) #> Error: missing values in ... options("na.action") </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>