1.5 NA

NA is a logical constant of length 1 that contains a missing value indicator. The NA coding can identify some situations.

  • ‘Not Available’, e.g. asking ‘what time is it?’ and there is no clock available.
  • ‘Not Applicable’, e.g. asking ‘are you pregnant, sir?’
  • ‘Not Announced/Answered’, e.g. being silent in an interrogation.
  • ‘Not Accessed’, e.g. the student’s Moodle page was not accessed throughout the semester.
?NA
(x <- c(NA, 1:3, NA, 1000))
## [1]   NA    1    2    3   NA 1000
is.na(x)
## [1]  TRUE FALSE FALSE FALSE  TRUE FALSE
sum(is.na(x))
## [1] 2
anyNA(x)
## [1] TRUE

The VIM library by (Kowarik and Templ 2016) provides tools for viewing missing and imputed values.

library(VIM)
(a <- aggr(sleep, sortVars = TRUE))

## 
##  Variables sorted by number of missings: 
##  Variable      Count
##      NonD 0.22580645
##     Dream 0.19354839
##     Sleep 0.06451613
##      Span 0.06451613
##      Gest 0.06451613
##   BodyWgt 0.00000000
##  BrainWgt 0.00000000
##      Pred 0.00000000
##       Exp 0.00000000
##    Danger 0.00000000
## 
##  Missings in variables:
##  Variable Count
##      NonD    14
##     Dream    12
##     Sleep     4
##      Span     4
##      Gest     4
summary(a)
## 
##  Missings per variable: 
##  Variable Count
##   BodyWgt     0
##  BrainWgt     0
##      NonD    14
##     Dream    12
##     Sleep     4
##      Span     4
##      Gest     4
##      Pred     0
##       Exp     0
##    Danger     0
## 
##  Missings in combinations of variables: 
##         Combinations Count   Percent
##  0:0:0:0:0:0:0:0:0:0    42 67.741935
##  0:0:0:0:0:0:1:0:0:0     3  4.838710
##  0:0:0:0:0:1:0:0:0:0     2  3.225806
##  0:0:0:0:0:1:1:0:0:0     1  1.612903
##  0:0:1:0:1:0:0:0:0:0     2  3.225806
##  0:0:1:1:0:0:0:0:0:0     9 14.516129
##  0:0:1:1:0:1:0:0:0:0     1  1.612903
##  0:0:1:1:1:0:0:0:0:0     2  3.225806

References

Kowarik, Alexander, and Matthias Templ. 2016. “Imputation with the R Package VIM.” Journal of Statistical Software 74 (7): 1–16. https://doi.org/10.18637/jss.v074.i07.