\Header{matrix}{Matrices}
\alias{as.matrix}{matrix}
\methalias{as.matrix.data.frame}{matrix}
\methalias{as.matrix.default}{matrix}
\alias{is.matrix}{matrix}
\keyword{array}{matrix}
\keyword{algebra}{matrix}
\begin{Description}\relax
\code{matrix} creates a matrix from the given set of values.

\code{as.matrix} attempts to turn its argument into a matrix.

\code{is.matrix} tests if its argument is a (strict) matrix.\end{Description}
\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{Arguments}
\begin{ldescription}
\item[\code{data}] an optional data vector.
\item[\code{nrow}] the desired number of rows
\item[\code{ncol}] the desired number of columns
\item[\code{byrow}] logical. If \code{FALSE}
(the default) the matrix is filled by columns, otherwise the matrix is
filled by rows.
\item[\code{dimnames}] A \code{\Link{dimnames}} attribute for the matrix: a
\code{list} of length 2.
\item[\code{x}] an \R{} object.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If either of \code{nrow} or \code{ncol} is
not given, an attempt is made to infer it from the length of
\code{data} and the other parameter.

\code{is.matrix} returns \code{TRUE} if \code{x} is a matrix (i.e., it
\emph{not} a \code{\Link{data.frame}} and has a \code{\Link{dim}}
attribute of length 2) and \code{FALSE} otherwise.\end{Details}
\begin{SeeAlso}\relax
\code{\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}

