\Header{matrix}{Matrices}
\alias{as.matrix}{matrix}
\alias{as.matrix.default}{matrix}
\alias{as.matrix.data.frame}{matrix}
\alias{is.matrix}{matrix}
\keyword{array}{matrix}
\keyword{algebra}{matrix}
\begin{Usage}
\begin{verbatim}
matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
as.matrix(x)
is.matrix(x)
\end{verbatim}
\end{Usage}
\begin{Description}
\texttt{matrix} creates a matrix from the given set of values.
\texttt{nrow} gives the desired number of rows and \texttt{ncol} the
desired number of columns.  If either of \texttt{nrow} or \texttt{ncol} is
not given, an attempt is made to infer it from the length of
\texttt{data} and the other parameter.  If \texttt{byrow} is \texttt{FALSE}
(the default) the matrix is filled by columns, otherwise the matrix is
filled by rows.  A \texttt{\Link{dimnames}} attribute for the matrix can be
specified with the optional \texttt{dimnames} argument (which thus has
to be a \texttt{\Link{list}} of length 2).

\texttt{as.matrix} attempts to turn its argument into a matrix.  This
function is generic with a default and a \texttt{\Link{data.frame}} method.

\texttt{is.matrix} returns \texttt{TRUE} if \texttt{x} is a matrix (i.e., it
\emph{not} a \texttt{\Link{data.frame}} and has a \texttt{\Link{dim}}
attribute of length 2) and \texttt{FALSE} otherwise.\end{Description}
\begin{SeeAlso}
\texttt{\Link{data.matrix}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
is.matrix(as.matrix(1:10))
data(warpbreaks)
!is.matrix(warpbreaks)# data.frame, NOT matrix!
str(warpbreaks)
str(as.matrix(warpbreaks))#using as.matrix.data.frame(.) method
\end{ExampleCode}
\end{Examples}

