I've recently been using the package tab
in R to build frequency tables.
Using the tabfreq()
or the tabmulti()
functions, the default output excludes NA values. Does anyone know the command to include NA values within these functions?
The table()
function in base R can display missing values (i.e. NAs) via useNA
, which takes several arguments: "no", "ifany", or "always".
data(airquality) # loads the built-in data frame, which has NAs
table(airquality$Ozone, useNA = "always") # always displays the number of missing values
table(airquality$Wind, useNA = "ifany") # only displays the number of missing values if there are some
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