vecNA: Frequency of Missing Values in a Vector

Description Usage Arguments Value See Also Examples

View source: R/quest_functions.R

Description

vecNA computes the frequency of missing values in an atomic vector. vecNA is essentially a wrapper for sum or mean + is.na or !is.na and can be useful for functional programming (e.g., lapply(FUN = vecNA)). It is also used by other functions in the quest package related to missing values (e.g., mean_if).

Usage

1
vecNA(x, prop = FALSE, ov = FALSE)

Arguments

x

atomic vector or list vector. If not a vector, it will be coerced to a vector via as.vector.

prop

logical vector of length 1 specifying whether the frequency of missing values should be returned as a proportion (TRUE) or a count (FALSE).

ov

logical vector of length 1 specifying whether the frequency of observed values (TRUE) should be returned rather than the frequency of missing values (FALSE).

Value

numeric vector of length 1 providing the frequency of missing values (or observed values if ov = TRUE). If prop = TRUE, the value will range from 0 to 1. If prop = FALSE, the value will range from 1 to length(x).

See Also

is.na rowNA colNA rowsNA

Examples

1
2
3
4
vecNA(airquality[[1]]) # count of missing values
vecNA(airquality[[1]], prop = TRUE) # proportion of missing values
vecNA(airquality[[1]], ov = TRUE) # count of observed values
vecNA(airquality[[1]], prop = TRUE, ov = TRUE) # proportion of observed values

quest documentation built on Sept. 10, 2021, 5:07 p.m.

Related to vecNA in quest...