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
`.rowNamesDF<-` is a (non-generic replacement) function to set
row names for data frames, with extra argument
This function only exists as workaround as we cannot easily change the
row.names<- generic without breaking legacy code in existing packages.
row.names(x) row.names(x) <- value .rowNamesDF(x, make.names=FALSE) <- value
object of class
"data.frame", or any other class for
which a method has been defined.
logical, i.e., one of
FALSE, NA, TRUE,
indicating what should happen if the specified row names, i.e.,
value, are invalid, e.g., duplicated or
NA. The default
(is back compatible),
FALSE, will signal an error, where
NA will “automatic” row names and
TRUE will call
make.names(value, unique=TRUE) for constructing valid
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
x with no duplicated nor missing values.
NULL is also allowed: see ‘Details’.
row.names returns a character vector.
row.names<- returns a data frame with the row names changed.
A data frame has (by definition) a vector of 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 ‘automatic’.
Row names are currently allowed to be integer or character, but
for backwards compatibility (with R <= 2.4.0)
always return a character vector. (Use
attr(x, "row.names") if
you need to retrieve an integer-valued set of row names.)
NULL for the value resets the row names to
seq_len(nrow(x)), regarded as ‘automatic’.
Chambers, J. M. (1992) Data for models. Chapter 3 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.
.row_names_info for the internal representations.