I just discovered this new function it seems to me to an improved version of !is.na, maybe wrapped into an apply(df, 1)
. Am I correct or the following:
> a<-c(1,2,4,NA,6,8)
> identical(complete.cases(a), !is.na(a))
[1] TRUE
it's not always true?
For an atomic vector, complete.cases
and is.na
will be identical. For more complex objects this will not be the case.
Eg, for, a data.frame is.na.data.frame
will return a logical matrix of the same dimension as the input.
test <- data.frame(a, b =1)
is.na(test)
# a b
# [1,] FALSE FALSE
# [2,] FALSE FALSE
# [3,] FALSE FALSE
# [4,] TRUE FALSE
# [5,] FALSE FALSE
#[6,] FALSE FALSE
complete.cases(test)
# [1] TRUE TRUE TRUE FALSE TRUE TRUE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With