groupData: Splitting a Matrix into a List of Matrices

View source: R/zenpath.R

groupDataR Documentation

Splitting a Matrix into a List of Matrices

Description

Takes a matrix x and groups its rows (or columns) as specified by indices. Returns a list of matrices, one for each group.

Usage

groupData(x, indices, byrow = FALSE)

Arguments

x

A matrix (or an object convertible to such via as.matrix()).

indices

list of vectors of indices according to which x is grouped; each vector of indices define a group.

byrow

logical indicating whether the grouping is done by row (byrow = TRUE) or by column (byrow = FALSE, the default).

Value

A list of matrices (one per group). Such a list, grouped by columns, is then typically passed on to zenplot().

Author(s)

Marius Hofert and Wayne Oldford

See Also

zenplot() which provides the zenplot.

Other tools related to constructing zenpaths: connect_pairs(), extract_pairs(), graph_pairs(), indexData(), zenpath()

Examples

## get a matrix
x <- matrix(1:15, ncol = 3)
colGroups <- list(c(1,2), list(2:3))
rowGroups <- list(c(1,4), list(2:3))
groupData(x, indices = colGroups)
groupData(x, indices = rowGroups, byrow = TRUE)



zenplots documentation built on Nov. 8, 2023, 1:10 a.m.