dimnames
attribute of an array.
This is a list of the same length as the dimension of the array.
dimnames(x) dimnames(x) <- value
dim(x)
, or
NULL
,
whose components have length equal to the corresponding dimension or zero.
x
if they exist, or
NULL
.
dimnames
of an object is a list whose length is
length(dim(x))
.
The
i
th element of
dimnames(x)
is either of length
0
(not allowed
for data frames or
bdFrame
s)
or is a vector of
dim(x)[i]
character strings, and in the latter case should be
thought of
as a set of labels for the
i
th dimension of
x
.
dimnames
attribute of
x
is created
or changed if
x
is an array or data frame and
value
is
compatible with
dim(x)
.
This is a generic function, there is a method for data frames and
bdFrame
s.
Arrays (may) have a
dimnames
attribute, and this is what is
reported on or changed.
The dimnames of a data frame or
bdFrame
are the
row.names
attribute and the
names
of the object.
To explicitly delete the
dimnames
attribute of an array (or matrix),
use
dimnames(x)<-NULL
.
To explicitly delete row or column names, see example below.
You may not remove the
dimnames
of a data frame or
bdFrame
.
The row and column
names must have the same length as the number or rows
and columns of the data frame or
bdFrame
.
Column names must be unique;
row names must be unique unless the data frame or
bdFrame
has a
non-
NULL
dup.row.names
attribute.
The
value
may be a character vector, or anything that
can be coerced to a character vector. However, it should not
be a
bdCharacter
or other
bdVector
;
you can convert these to an ordinary vector using
bd.coerce
Instead of using
names
to replace row names from a matrix,
use
rowIds
or
dimnames
.
Array subscripts retain
dimnames
; see
Subscript
.
dimnames(iris)[[3]] # iris species my.matrix <- matrix(1:12, 3) dimnames(my.matrix) <- list(NULL, c("red", "blue", "brown", "green")) dimnames(my.matrix)[[1]] <- c("a", "b", "c") # add row names dimnames(my.matrix)[[1]] <- character(0) # remove row names dimnames(my.matrix)[[2]] <- c("d", "e", "f", "g") # change col names # Note -- when creating dimnames initially you may use NULL as # as a shortcut for character(0), but not when modifying dimnames. # This is illegal: dimnames(my.matrix)[[1]] <- NULL