\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.
It is generic: you can write methods to handle
of specific classes of objects, see \link{InternalMethods}.\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
is \emph{not} a \code{\Link{data.frame}} and has a \code{\Link{dim}}
attribute of length 2) and \code{FALSE} otherwise.

\code{as.matrix} is a generic function. The method for data frames
will convert any non-numeric column into a character vector using
\code{\Link{format}} and so return a character matrix.\end{Details}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.\end{References}
\begin{SeeAlso}\relax
\code{\Link{data.matrix}}, which attempts to convert to a numeric 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}

