Learn R Programming

forstringr (version 1.0.0)

length_omit_na: Length of an object

Description

length_omitna() counts only non-missing elements of a vector.

Usage

length_omit_na(x)

Value

An integer

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

Run this code

ethnicity <- c("Hausa", NA, "Yoruba", "Igbo", NA, "Fulani", "Kanuri", "Others")

length_omit_na(ethnicity)

length(ethnicity)

Run the code above in your browser using DataLab