all_na: Tests for missing values

Description Usage Arguments Details Value See Also Examples

Description

Test if all values are missing

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
all_na(x)

## Default S3 method:
all_na(x)

any_na(x)

is_na()

which_na(x)

Arguments

x

object to test.

Details

These are S3 Generics that provide default methods.

all_na reports if all values are missing.

any_na reports if any values are missing. If always returns a logical scalar.

is_na is a wrapper around base::is.na() created to keep stylistic consistenct with the other functions.

which_na is implemented as which( is.na(x) ). It is a S3 generic function.

Value

logical scalar indicating if values are missing.

logical scalar; either TRUE or FALSE.

integer of indexes of x that corerspond to elements of x that are missing (NA). Names of the result are set to the names of x.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
  all_na( c( NA, NA, 1 ) )    # FALSE
  all_na( c( NA, NA, NA ) )   # TRUE
  
  df <- data.frame( char = rep(NA_character_, 3), nums=1:3)
  all_na(df)  # FALSE
  
  df <- data.frame( char = rep(NA_character_, 3), nums=rep(NA_real_,3))
  all_na(df)  # TRUE
  
  any_na( 1:10 )           # FALSE
  any_na( c( 1, NA, 3 ) )  # TRUE


  x <- c( 1, NA, NA, 4:6 )
  which_na(x)
  
  names(x) <- letters[1:6]
  which_na(x)
 

na.tools documentation built on May 2, 2019, 8:24 a.m.