recodeDimnames: Recode dimension names

Description Usage Arguments Details Functions Note Examples

View source: R/array_transform.R

Description

recodeDimnames renames dimension identifiers and dimension levels (useful before plotting). recodeDimnames_ does the same in place, thus without making any copy.

Usage

1
2
3
recodeDimnames(dat, dim_levels = NULL, dim_ids = NULL)

recodeDimnames_(dat, dim_levels = NULL, dim_ids = NULL)

Arguments

dat

an array with dimension names

dim_levels

a named list of named character vectors. The name of the list element identifies the dimension, the names of the character vector refer to the original dimension levels, and the values of the character vector correspond to the new dimension levels. See also Details.

dim_ids

a named character vector which is used to rename the dimension identifiers

Details

recodeDimnames goes through the 'dim_levels' argument first. If a character vector in 'dim_levels' is not named, it must be of the same length as the length of the given dimension.

Functions

Note

Use recodeDimnames_ with extra care because it modifies in place all objects which 'dat' refers to.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## load example data
data(erps)

## recode the 'subst', 'ident', and 'transp' levels of the 'stimclass' 
## dimension to 'Substitution', 'Identical', and 'Transposition', 
## respectively; also rename the 'stimclass' dimension name to 
## 'Stimulus class'
erps2 <- recodeDimnames(erps, 
                        list(stimclass = c(subst = "Substitution",
                                           ident = "Identical",
                                           transp = "Transposition")),
                        c(stimclass = "Stimulus class"))
 

tdeenes/eegR documentation built on April 19, 2021, 4:17 p.m.