NAInfRemoveMultiBlock: NAInfRemoveMultiBlock

View source: R/NAInfRemoveMultiBlock.R

NAInfRemoveMultiBlockR Documentation

NAInfRemoveMultiBlock

Description

Remove NA and Infinite values from a MultiBlock object in a single pass. Variables whose combined count of NA and Infinite values meets or exceeds minfrac * nrow are discarded first. Remaining Infinite values are then replaced according to inf.method; remaining NA values are imputed according to na.method.

Usage

NAInfRemoveMultiBlock(
  MB,
  blocks = NULL,
  minfrac = 0.5,
  na.method = c("none", "zero", "median", "discard", "fixed.value", "fixed.value.all",
    "fixed.noise", "random.noise", "QRILC")[8],
  inf.method = c("none", "fixed.noise", "random.noise")[3],
  constant = 0,
  factor.NA = 0.5,
  sd.noise = 0.3,
  tune.sigma = 1,
  showWarning = TRUE
)

Arguments

MB

The MultiBlock object.

blocks

Blocks to process: a vector of integers or block names (optional; all blocks are processed when omitted).

minfrac

Minimum fraction of valid (non-NA, finite) values required to retain a variable. Variables at or below this threshold are discarded. Default: 0.5.

na.method

Imputation method for remaining NA values after the minfrac filter. One of: 'none' (keep NAs), 'zero', 'median', 'discard' (drop columns still containing NAs), 'fixed.value', 'fixed.value.all', 'fixed.noise', 'random.noise', 'QRILC'. Default: 'random.noise'.

inf.method

Replacement method for remaining Infinite values after the minfrac filter. One of: 'none' (keep Inf), 'fixed.noise', 'random.noise'. Default: 'random.noise'.

constant

For na.method = 'fixed.value': value to replace NAs. For na.method = 'fixed.value.all': value added to every element (NAs are then set to this value). Default: 0.

factor.NA

Noise factor used by 'fixed.noise' and 'random.noise' for both NA and Inf imputation. For NA and -Inf: the replacement mean equals col_min * factor.NA. For +Inf: col_max / factor.NA. Default: 0.5.

sd.noise

Standard-deviation factor for 'random.noise': SD = abs(mean * sd.noise). Default: 0.3.

tune.sigma

Tuning scalar for na.method = 'QRILC'. Default: 1 (Gaussian complete-data assumption).

showWarning

If TRUE, emit a warning when variables are discarded by the minfrac filter. Default: TRUE.

Value

The processed MultiBlock object.

Examples

b1 <- matrix(rnorm(500), 10, 50)
b2 <- matrix(rnorm(800), 10, 80)
b2[c(2, 3, 5), c(1, 2, 3)] <- NA
b2[c(1, 4), c(4, 5)] <- Inf
mb <- MultiBlock(Data = list(b1 = b1, b2 = b2))
mb <- NAInfRemoveMultiBlock(mb, na.method = "zero", inf.method = "fixed.noise")

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