\HeaderA{na.handling}{Handling of Missing Values}{na.handling}
\keyword{utilities}{na.handling}
\begin{Description}\relax
Removes missing values from a data set either by replacing them or
by removing the rows that contain missing values.
\end{Description}
\begin{Usage}
\begin{verbatim}
  na.handling(X, na.replace = TRUE, na.method = "mean")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{X}] a matrix
\item[\code{na.replace}] If \code{TRUE}, missing values are replaced by
the rowwise statistic specified by \code{na.method}. If 
\code{FALSE}, all rows with one or more missing values are
removed
\item[\code{na.method}] character string specifying the statistic
with which the missing values should be replaced. Must be either
\code{"mean"} or \code{"median"}
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Since missing values are replaced by either the rowwise mean or median,
\code{na.handling} can only handle continuous data. There is, however, no
check if the data is continuous or categorical/discrete.

If there are no or only one non-missing value in a row, \code{na.handling}
will remove this row from the data set even if \code{na.replace=TRUE}.
\end{Details}
\begin{Value}
\begin{ldescription}
\item[\code{X}] matrix without missing values. The number of rows of \code{X} can
differ from the number of rows of the input matrix \code{X}, since all
rows with either less than one non-missing value (if \code{na.replace=TRUE})
or with at least one missing value (if \code{na.replace=FALSE}) are
removed
\item[\code{NA.genes}] the rows of the input matrix \code{X} that are removed and
thus are excluded from the output matrix \code{X}
\end{ldescription}
\end{Value}
\begin{Author}\relax
Holger Schwender, \email{holger.schw@gmx.de}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{na.replace.cont}{na.replace.cont}},\code{\LinkA{na.replace.dist}{na.replace.dist}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
   mat<-matrix(1:20,5,4)
   mat[1,2]<-NA
   mat
   
   # Replace the missing value by the mean of the first row.
   na.handling(mat)
   
   # Remove the first row.
   na.handling(mat,na.replace=FALSE)
   
   # Replace the missing value in the first row by the mean of
   # this row, and remove the second row containing only NAs.
   mat[2,]<-NA
   mat
   na.handling(mat)
\end{ExampleCode}
\end{Examples}


