View source: R/ProcessMultiBlock.R
ProcessMultiBlock | R Documentation |
Apply a custom function to Process the MultiBlocks and/or to select some blocks. If multiple functions are used, the order followed is FUN, FUN.SelectVars, and FUN.SelecBlocks.
ProcessMultiBlock(
MB = MB,
blocks = NULL,
vars = NULL,
FUN = NULL,
FUN.SelectVars = NULL,
FUN.SelectBlocks = NULL
)
MB |
The MultiBlocks structure. |
blocks |
The blocks to apply the processing. It can be a vector of integers or a vector with the block names. Facultative. |
vars |
The variables to kept. It is a list object with the same length as 'blocks'. Each element in the list contains the position of the variables in the nth block. |
FUN |
The function used for data processing. |
FUN.SelectVars |
The function used to select variables. If applied to a numeric data matrix, it should return a vector of TRUE/FALSE with the same length as ncol. |
FUN.SelectBlocks |
The function used to select blocks. If applied to a numeric data matrix, it should return TRUE/FALSE. |
The MultiBlock
b1 = matrix(rnorm(500),10,50)
b2 = matrix(rnorm(800),10,80)
# Build MultiBlock by adding one data block at a time:0))
mb <- BuildMultiBlock(b1, newSamples = paste0('sample_',1:1
mb <- BuildMultiBlock(b2, growingMB = mb)
# Prepare custom functions
BY100 <- function(x) { 100*(x/max(x)) } # Normalize each block to 100%
norm100000 <- function(x){norm(x)>100000} # Keep blocks with a norm higher than 100000.
thr5 <- function(x) {x > max(x, na.rm = TRUE) * 0.05} # Keep variables larger than 5% in the block.
mb <- ProcessMultiBlock(MB, FUN = BY100, FUN.SelectBlocks = norm100000, FUN.SelectVars = thr5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.