Learn R Programming

memisc (version 0.11-9)

dimrename: Change dimnames, rownames, or colnames

Description

These functions provide an easy way to change the dimnames, rownames or colnames of an array.

Usage

dimrename(x, dim = 1, ...)
rowrename(x, ...)
colrename(x, ...)

Arguments

x
An array with dimnames
dim
A vector that indicates the dimensions
...
A sequence of named arguments

Value

  • Object x with changed dimnames.

Details

dimrename changes the dimnames of x along dimension(s) dim according to the remaining arguments. The argument names are the old names, the values are the new names. rowrename is a shorthand for changing the rownames, colrename is a shorthand for changing the colnames of a matrix or matrix-like object.

Examples

Run this code
m <- matrix(1,2,2)
rownames(m) <- letters[1:2]
colnames(m) <- LETTERS[1:2]
m
dimrename(m,1,a="first",b="second")
dimrename(m,1,A="first",B="second")
dimrename(m,2,"A"="first",B="second")

rowrename(m,a="first",b="second")
colrename(m,"A"="first",B="second")

Run the code above in your browser using DataLab