na.omit.mat: Omit Rows with NA Values from a Matrix

View source: R/CodeAndRoll2.R

na.omit.matR Documentation

Omit Rows with NA Values from a Matrix

Description

Removes rows from a matrix based on the presence of NA values. Can remove rows with any NA values or only those completely filled with NAs.

Usage

## S3 method for class 'mat'
na.omit(mat, any = TRUE)

Arguments

mat

Input matrix from which rows with NAs are to be omitted.

any

Logical; if TRUE (default), removes rows containing any NA values. If FALSE, removes only rows completely filled with NA values.

Value

A matrix with rows containing NA values omitted according to the specified criteria.

Examples

mat <- matrix(c(1, NA, 3, 4, 5, NA, NA, NA, 9), ncol = 3)
na.omit.mat(mat) # Default, any = TRUE
na.omit.mat(mat, any = FALSE)


vertesy/CodeAndRoll2 documentation built on Nov. 20, 2024, 5:23 a.m.