has_NA: Identify NA Values by Row

View source: R/S03_Utilities.R

has_NAR Documentation

Identify NA Values by Row

Description

Identifies rows in a matrix or data frame that contain any (or all) NA values.

Usage

has_NA(x, any = TRUE)

Arguments

x

A matrix or data frame.

any

Logical; if TRUE check if any observation in the row is a NA value, else checks if all observations are NA.

Value

A logical vector with values of TRUE for rows with any NA values (or rows where all values are NA when any = FALSE).

Examples

x <- matrix(rnorm(9), 3, 3)
x[2, 3] <- NA
has_NA(x)
x <- data.frame(A = c(1, 2, NA), B = 0)
has_NA(x)

x <- matrix(rnorm(9), 3, 3)
x[2, ] <- NA
x[3, 1] <- NA
has_NA(x, any = FALSE)

rettopnivek/arfpam documentation built on Oct. 20, 2024, 7:24 p.m.