2.5 Using table() to Spot Irregularities

When a variable takes on a limited range of values it is often useful to screen for irregularities or invalid values. This is common across all variable types and can occur for character strings, numeric, integer and factor types. For example, we would expect the grad variable to only take the values of zero or one. We can use the table() function to quickly confirm this.

By default table() simply omits any values coded as NA. To include a count of the NA values use the useNA argument of table() as follows:

table(wisc3raw$grad, useNA = "always")
## 
##    0    1 <NA> 
##  158   46    0