Retrieve or set the dimnames of an object.
dimnames(x)
dimnames(x) <- value<p></p><p>provideDimnames(x, sep = "", base = list(LETTERS), unique = TRUE)</p>
| Parameter | Description |
|---|---|
x |
an R object, for example a matrix, array or data frame. |
value |
a possible value for dimnames(x): see the ‘Value’ section. |
sep |
a character string, used to separate base symbols and digits in the constructed dimnames. |
base |
a non-empty list of character vectors. The list components are used in turn (and recycled when needed) to construct replacements for empty dimnames components. See also the examples. |
unique |
logical indicating that the dimnames constructed are unique within each dimension in the sense of make.unique. |
# NOT RUN {
## simple versions of rownames and colnames
## could be defined as follows
rownames0 <- function(x) dimnames(x)[[1]]
colnames0 <- function(x) dimnames(x)[[2]]
(dn <- dimnames(A <- provideDimnames(N <- array(1:24, dim = 2:4))))
A0 <- A; dimnames(A)[2:3] <- list(NULL)
stopifnot(identical(A0, provideDimnames(A)))
strd <- function(x) utils::str(dimnames(x))
strd(provideDimnames(A, base= list(letters[-(1:9)], tail(LETTERS))))
strd(provideDimnames(N, base= list(letters[-(1:9)], tail(LETTERS)))) # recycling
strd(provideDimnames(A, base= list(c("AA","BB")))) # recycling on both levels
## set "empty dimnames":
provideDimnames(rbind(1, 2:3), base = list(""), unique=FALSE)
# }