Row and Columnn Names
Usage
rownames(x, do.NULL = TRUE, prefix = "row")
rownames(x) <- namevector
colnames(x, do.NULL = TRUE, prefix = "col")
colnames(x) <- namevector
Description
Retrieve or set the row or column names of an object (the first or
second component of its dimnames
).Details
If do.NULL
is FALSE
, a character vector (of length
NROW(x)
or NCOL(x)
is returned in any
case, prepending prefix
to simple numbers, if
dimnames(x)[[i]]
(i =
1 or 2) is NULL
.See Also
dimnames
, case.names
,
variable.names
.Examples
m0 <- matrix(NA, 4, 0)
m2 <- cbind(1,1:4)
rownames(m0)
m0 <- matrix(NA, 4, 0)
m2 <- cbind(1,1:4)
rownames(m0)
colnames(m2, do.NULL = FALSE)
colnames(m2) <- c("x","Y")
rownames(m2) <- rownames(m2, do.NULL = FALSE, prefix = "Obs.")
m2
colnames(m2, do.NULL = FALSE)
colnames(m2) <- c("x","Y")
rownames(m2) <- rownames(m2, do.NULL = FALSE, prefix = "Obs.")
m2