rownames(x, do.NULL = TRUE, prefix = "row") rownames(x) <- valuecolnames(x, do.NULL = TRUE, prefix = "col") colnames(x) <- value
FALSEand names are
NULL, names are created.
dimnames(x). For a matrix or array this is either
NULLor a character vector of non-zero length equal to the appropriate dimension.
x. If the object has
dimnamesthe first component is used as the row names, and the second component (if any) is used for the column names. For a data frame,
namesrespectively, but the latter are preferred.
FALSE, a character vector (of length
NCOL(x)) is returned in any
prefix to simple numbers, if there are no
dimnames or the corresponding component of the dimnames is
The replacement methods for arrays/matrices coerce vector and factor
value to character, but do not dispatch methods for
For a data frame,
rownames should be a
character vector of non-duplicated and non-missing names (this is
enforced), and for
colnames a character vector of (preferably)
unique syntactically-valid names. In both cases,
value will be
as.character, and setting
will convert the row names to character.
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