Learn R Programming

zenplots (version 1.0.6)

groupData: 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)

Value

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

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).

Author

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

Run this code
## 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)


Run the code above in your browser using DataLab