split_matrix: Split matrix

Description Usage Arguments Details Value Author(s) Examples

Description

Split a matrix by rows or columns into a list.

Usage

1
split_matrix(x, by = c("row", "col"))

Arguments

x

A matrix to by split

Either

'row' or 'col' indicating the direction of the split. Defaults to 'row'.

Details

A shorthand not preserving rownames is split(x, row(x)) for splitting by rows and split(x, col(x)) for splitting by columns.

Value

A list containing the row or columns of the matrix.

Author(s)

Dominik Mueller

Examples

1
2
3
4
x <- matrix(seq_len(4L), nrow = 2L) 
dimnames(x) <- list(c('a', 'b'), c('c', 'd'))
split_matrix(x, 'row')
split_matrix(x, 'col')

DominikMueller64/dmisc documentation built on May 6, 2019, 2:52 p.m.