complete.cases
Find Complete Cases of Observations

Description

Identifies cases in rows across an arbitrary collection of vectors, matrices, or data frames that contain missing values (NAs). A complete case exists when there are no missing values (NAs) in the row.

Usage

complete.cases(...)

Arguments

... an arbitrary collection of vectors, matrices, and data frames where all of the arguments have the same number of rows or, in the case of vectors, the same number of elements.
Value
returns a logical vector that specifies TRUE for complete cases, that is observations that do not have any missing values (NAs) in that row across the entire collection, and FALSE for incomplete cases, observations that contain at least one missing value (NA).
See Also
is.na, na.omit, na.fail
Examples
data(ethanol, package = "Sdatasets")

# Make up a data set with missing values: y <- ethanol[, 1] # response variable y[c(19, 23, 29, 31)] <- NA x <- ethanol[, -1] # x is the model matrix x[c(37, 41, 43, 47),] <- NA

all(complete.cases(y) != is.na(y)) # Should be TRUE

ok <- complete.cases(y, x) sum(!ok) # Should be 8

Package stats version 6.1.4-13
Package Index