View source: R/MultiBlock2Matrix.R
| MultiBlock2Matrix | R Documentation |
Combines the blocks of a MultiBlock into a single matrix by column-binding the selected blocks. Useful for computing summary statistics across the whole MultiBlock (e.g. maximum value).
MultiBlock2Matrix(MB = MB, blocks = NULL, vars = NULL)
MB |
A |
blocks |
The blocks to combine. A vector of integers (block indices) or a vector of block names. When omitted, all blocks are included. |
vars |
The variables to keep. A list of the same length as |
Blocks are column-bound in the order given by blocks. Row names of the output matrix
are the sample names of MB. Column names are the variable names; if the same variable
name appears in more than one block, duplicates are disambiguated by appending
.<block_name> to all occurrences of the repeated name, and a warning is issued.
A numeric matrix with rows corresponding to samples and columns corresponding to the variables of the selected blocks concatenated in order.
MultiBlock, ProcessMultiBlock
b1 <- matrix(rnorm(500), 10, 50)
b2 <- matrix(rnorm(800), 10, 80)
mb <- MultiBlock(Data = list(b1 = b1, b2 = b2))
# Combine all blocks into a matrix and compute a summary statistic:
mat <- MultiBlock2Matrix(mb)
max(mat)
# Combine only the first block, keeping variables 1-10:
mat <- MultiBlock2Matrix(mb, blocks = 1, vars = list(1:10))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.