MultiBlock2Matrix: MultiBlock2Matrix

View source: R/MultiBlock2Matrix.R

MultiBlock2MatrixR Documentation

MultiBlock2Matrix

Description

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

Usage

MultiBlock2Matrix(MB = MB, blocks = NULL, vars = NULL)

Arguments

MB

A MultiBlock object.

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. Each element contains the indices (integer) or names (character) of the variables to retain from the corresponding block. When omitted, all variables in each block are included.

Details

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.

Value

A numeric matrix with rows corresponding to samples and columns corresponding to the variables of the selected blocks concatenated in order.

See Also

MultiBlock, ProcessMultiBlock

Examples

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

R.ComDim documentation built on May 13, 2026, 9:07 a.m.