\HeaderA{row.names}{Get and Set Row Names for Data Frames}{row.names}
\methaliasA{row.names.data.frame}{row.names}{row.names.data.frame}
\methaliasA{row.names.default}{row.names}{row.names.default}
\aliasA{row.names<\Rdash}{row.names}{row.names<.Rdash.}
\methaliasA{row.names<\Rdash.data.frame}{row.names}{row.names<.Rdash..data.frame}
\methaliasA{row.names<\Rdash.default}{row.names}{row.names<.Rdash..default}
\keyword{classes}{row.names}
\keyword{methods}{row.names}
\begin{Description}\relax
All data frames have a row names attribute, a character vector of
length the number of rows with no duplicates nor missing values.

For convenience, these are generic functions for which users can write
other methods, and there are default methods for arrays.  The
description here is for the \code{data.frame} method.
\end{Description}
\begin{Usage}
\begin{verbatim}
row.names(x)
row.names(x) <- value
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] object of class \code{"data.frame"}, or any other class for
which a method has been defined.
\item[\code{value}] an object to be coerced to character unless an integer
vector.  It should have (after coercion) the same length as the
number of rows of \code{x} with no duplicated nor missing values.
\code{NULL} is also allowed: see \sQuote{Details}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
A data frame has (by definition) a vector of \emph{row names} which
has length the number of rows in the data frame, and contains neither
missing nor duplicated values.  Where a row names sequence has been
added by the software to meet this requirement, they are regarded as
\sQuote{automatic}.

Row names were character are allowed to be integer or character, but
for backwards compatibility (with \R{} <= 2.4.0) \code{row.names} will
always return a character vector.  (Use \code{attr(x, "row.names")} if
you need an integer value.)

Using \code{NULL} for the value resets the row names to
\code{seq\_len(nrow(x))}, regarded as \sQuote{automatic}.
\end{Details}
\begin{Value}
\code{row.names} returns a character vector.

\code{row.names<-} returns a data frame with the row names changed.
\end{Value}
\begin{Note}\relax
\code{row.names} is similar to \code{\LinkA{rownames}{rownames}} for arrays, and
it has a method that calls \code{rownames} for an array argument.

Row names of the form \code{1:n} for \code{n > 2} are stored
internally in a compact form, which might be seen from C code or by
deparsing but never via \code{row.names} or
\code{\LinkA{attr}{attr}(x, "row.names")}.  Additionally, some names of this
sort are marked as \sQuote{automatic} and handled differently by
\code{\LinkA{as.matrix}{as.matrix}} and \code{\LinkA{data.matrix}{data.matrix}} (and potentially
other functions).  (All zero-row data frames are regarded as having
automatic row.names.)
\end{Note}
\begin{References}\relax
Chambers, J. M. (1992)
\emph{Data for models.}
Chapter 3 of \emph{Statistical Models in S}
eds J. M. Chambers and T. J. Hastie, Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{data.frame}{data.frame}}, \code{\LinkA{rownames}{rownames}}, \code{\LinkA{names}{names}}.

\code{\LinkA{.row\_names\_info}{.row.Rul.names.Rul.info}} for the internal representations.
\end{SeeAlso}

