| list_of_rows_or_cols {matsbyname} | R Documentation |
Named list of rows or columns of matrices
Description
This function takes matrix m and converts it to a list of
single-row (if margin == 1) or single-column(if margin == 2)
matrices.
Each item in the list is named for its row (if margin == 1)
or column (if margin == 2).
Usage
list_of_rows_or_cols(a, margin)
Arguments
a |
a matrix or list of matrices (say, from a column of a data frame) |
margin |
the margin of the matrices to be extracted ( |
Details
Note that the result provides column vectors, regardless of the value of margin.
Value
a named list of rows or columns extracted from m
Examples
m <- matrix(data = c(1:6),
nrow = 2, ncol = 3,
dimnames = list(c("p1", "p2"), c("i1", "i2", "i3"))) %>%
setrowtype(rowtype = "Products") %>% setcoltype(coltype = "Industries")
list_of_rows_or_cols(m, margin = 1)
list_of_rows_or_cols(m, margin = 2)
[Package matsbyname version 0.6.10 Index]