length_omitna()
counts only non-missing elements of a vector.
Arguments
- x
Input vector. Either a vector, or something coercible to one.
See also
length()
counts all the elements in a vector including those that are missing (NAs).
Examples
ethnicity <- c("Hausa", NA, "Yoruba", "Igbo", NA, "Fulani", "Kanuri", "Others")
length_omit_na(ethnicity)
#> [1] 6
length(ethnicity)
#> [1] 8