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

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

See also

zenplot() which provides the zenplot.

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

Author

Marius Hofert and Wayne Oldford

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)
#> [[1]]
#>      [,1] [,2]
#> [1,]    1    6
#> [2,]    2    7
#> [3,]    3    8
#> [4,]    4    9
#> [5,]    5   10
#> 
#> [[2]]
#>      [,1] [,2]
#> [1,]    6   11
#> [2,]    7   12
#> [3,]    8   13
#> [4,]    9   14
#> [5,]   10   15
#> 
groupData(x, indices = rowGroups, byrow = TRUE)
#> [[1]]
#>      [,1] [,2] [,3]
#> [1,]    1    6   11
#> [2,]    4    9   14
#> 
#> [[2]]
#>      [,1] [,2] [,3]
#> [1,]    2    7   12
#> [2,]    3    8   13
#>