8 numNA()

Similar to Stata,4 numNA counts the number of missing values: if m is set to 1, then it counts the number of missing values per row; if set to 2, then it counts the number of missing values per column; otherwise, it counts the total number of missing values.

numNA(airquality)
## [1] 44

8.1 rowNA()/colNA()

The function rowNA() is the equivalent of numNA(x, 1), where x is a data frame. It counts the number of missing values per row. The function colNA() does the same but per column.

rowNA(airquality)
##   [1] 0 0 0 0 2 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 2 0 0 0 0 1 1 1 1 1 1
##  [38] 0 1 0 0 1 1 0 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 1 0 0 0 0 0 0 1 0 0
##  [75] 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 0 0 0 1 0 0 0 0
## [112] 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [149] 0 1 0 0 0
colNA(airquality)
##   Ozone Solar.R    Wind    Temp   Month     Day 
##      37       7       0       0       0       0