\HeaderA{na.fail}{Handle Missing Values in Objects}{na.fail}
\aliasA{na.exclude}{na.fail}{na.exclude}
\methaliasA{na.exclude.data.frame}{na.fail}{na.exclude.data.frame}
\methaliasA{na.exclude.default}{na.fail}{na.exclude.default}
\methaliasA{na.fail.default}{na.fail}{na.fail.default}
\aliasA{na.omit}{na.fail}{na.omit}
\methaliasA{na.omit.data.frame}{na.fail}{na.omit.data.frame}
\methaliasA{na.omit.default}{na.fail}{na.omit.default}
\aliasA{na.pass}{na.fail}{na.pass}
\keyword{NA}{na.fail}
\begin{Description}\relax
These generic functions are useful for dealing with \code{\LinkA{NA}{NA}}s
in e.g., data frames.
\code{na.fail} returns the object if it does not contain any
missing values, and signals an error otherwise.
\code{na.omit} returns the object with incomplete cases removed.
\code{na.pass} returns the object unchanged.
\end{Description}
\begin{Usage}
\begin{verbatim}
na.fail(object, ...)
na.omit(object, ...)
na.exclude(object, ...)
na.pass(object, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object}] an \R{} object, typically a data frame
\item[\code{...}] further arguments special methods could require.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
At present these will handle vectors, matrices and data frames
comprising vectors and matrices (only).

If \code{na.omit} removes cases, the row numbers of the cases form the
\code{"na.action"} attribute of the result, of class \code{"omit"}.

\code{na.exclude} differs from \code{na.omit} only in the class of the
\code{"na.action"} attribute of the result, which is
\code{"exclude"}.  This gives different behaviour in functions making
use of \code{\LinkA{naresid}{naresid}} and \code{\LinkA{napredict}{napredict}}: when
\code{na.exclude} is used the residuals and predictions are padded to
the correct length by inserting \code{NA}s for cases omitted by
\code{na.exclude}.
\end{Details}
\begin{References}\relax
Chambers, J. M. and Hastie, T. J. (1992)
\emph{Statistical Models in S.}
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{na.action}{na.action}};
\code{\LinkA{options}{options}} with argument \code{na.action} for setting
\dQuote{NA actions};
and \code{\LinkA{lm}{lm}} and \code{\LinkA{glm}{glm}} for functions using these.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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")
\end{ExampleCode}
\end{Examples}

