complete.cases | R Documentation |
Return a logical vector indicating which cases are complete, i.e., have no missing values.
complete.cases(...)
... |
a sequence of vectors, matrices and data frames. |
A logical vector specifying which observations/rows have no missing values across the entire sequence.
A current limitation of this function is that it uses low level
functions to determine lengths and missingness, ignoring the
class. This will lead to spurious errors when some columns
have classes with length
or is.na
methods, for example "POSIXlt"
, as described
in \Sexpr[results=rd]{tools:::Rd_expr_PR(16648)}.
is.na
,
na.omit
,
na.fail
.
x <- airquality[, -1] # x is a regression design matrix y <- airquality[, 1] # y is the corresponding response stopifnot(complete.cases(y) != is.na(y)) ok <- complete.cases(x, y) sum(!ok) # how many are not "ok" ? x <- x[ok,] y <- y[ok]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.