\HeaderA{row/colnames}{Row and Column Names}{row/colnames}
\aliasA{colnames}{row/colnames}{colnames}
\aliasA{colnames<\Rdash}{row/colnames}{colnames<.Rdash.}
\aliasA{rownames}{row/colnames}{rownames}
\aliasA{rownames<\Rdash}{row/colnames}{rownames<.Rdash.}
\keyword{array}{row/colnames}
\keyword{manip}{row/colnames}
\begin{Description}\relax
Retrieve or set the row or column names of a matrix-like object.
\end{Description}
\begin{Usage}
\begin{verbatim}
rownames(x, do.NULL = TRUE, prefix = "row")
rownames(x) <- value

colnames(x, do.NULL = TRUE, prefix = "col")
colnames(x) <- value
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a matrix-like \R{} object, with at least two dimensions for
\code{colnames}.
\item[\code{do.NULL}] logical.  Should this create names if they are
\code{NULL}?
\item[\code{prefix}] for created names.
\item[\code{value}] a valid value for that component of
\code{\LinkA{dimnames}{dimnames}(x)}.  For a matrix or array this is either
\code{NULL} or a character vector of length the appropriate
dimension.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The extractor functions try to do something sensible for any
matrix-like object \code{x}.  If the object has \code{\LinkA{dimnames}{dimnames}}
the first component is used as the row names, and the second component
(if any) is used for the col names.  For a data frame, \code{rownames}
and \code{colnames} are equivalent to \code{\LinkA{row.names}{row.names}} and
\code{\LinkA{names}{names}} respectively.

If \code{do.NULL} is \code{FALSE}, a character vector (of length
\code{\LinkA{NROW}{NROW}(x)} or \code{\LinkA{NCOL}{NCOL}(x)}) is returned in any
case, prepending \code{prefix} to simple numbers, if there are no
dimnames or the corresponding component of the dimnames is \code{NULL}.

For a data frame, \code{value} for \code{rownames} should be a
character vector of unique names, and for \code{colnames} a character
vector of unique syntactically-valid names.  (Note: uniqueness and
validity are not enforced.)
\end{Details}
\begin{SeeAlso}\relax
\code{\LinkA{dimnames}{dimnames}},
\code{\LinkA{case.names}{case.names}},
\code{\LinkA{variable.names}{variable.names}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
m0 <- matrix(NA, 4, 0)
rownames(m0)

m2 <- cbind(1,1:4)
colnames(m2, do.NULL = FALSE)
colnames(m2) <- c("x","Y")
rownames(m2) <- rownames(m2, do.NULL = FALSE, prefix = "Obs.")
m2
\end{ExampleCode}
\end{Examples}

