This help topic is for R version 1.7.1. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/dimnames.html
dimnames {base}R Documentation

Dimnames of an Object

Description

Retrieve or set the dimnames of an object.

Usage

dimnames(x)
dimnames(x) <- nlist

Arguments

x

an R object, for example a matrix, array or data frame.

nlist

a possible value for dimnames(x): see below.

Details

The functions dimnames and dimnames<- are generic.

For an array (and hence in particular, for a matrix), they retrieve or set the dimnames attribute (see attributes) of the object. The list nlist can have names, and these will be used to label the dimensions of the array where appropriate.

Both have methods for data frames. The dimnames of a data frame are its row.names attribute and its names.

Value

The dimnames of a matrix or array can be NULL or a list of the same length as dim(x). If a list, its components are either NULL or a character vector the length of the appropriate dimension of x.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth \& Brooks/Cole.

See Also

rownames, colnames; array, matrix, data.frame.

Examples

## simple versions of rownames and colnames
## could be defined as follows
rownames0 <- function(x) dimnames(x)[[1]]
colnames0 <- function(x) dimnames(x)[[2]]

[Package base version 1.7.1 ]