impute: Perform simple imputation on rows of a matrix

View source: R/utils.R

imputeR Documentation

Perform simple imputation on rows of a matrix

Description

Impute NA values for each row of a matrix.

Usage

impute(x, fun = median)

Arguments

x

numeric matrix or data.frame that can be converted to a numeric matrix

fun

Imputation function to apply to rows of the matrix. Default median

Value

Matrix with imputed values

Examples

# Create a matrix of values with NAs
X <- matrix(runif(25), 5, dimnames = list(paste0("CpG", 1:5), paste0("Sample", 1:5)))
X[sample.int(25, 5)] <- NA
X

# Impute missing values with row medians
impute(X)

# Impute missing values with row mins
impute(X, min)

coriell-research/coriell documentation built on March 29, 2025, 2:19 p.m.