colNA: Frequency of Missing Values by Column

Description Usage Arguments Value See Also Examples

View source: R/quest_functions.R

Description

rowNA compute the frequency of missing values in a matrix by column. This function essentially does apply(X = x, MARGIN = 2, FUN = vecNA). It is also used by other functions in the quest package related to missing values (e.g., colMeans_if).

Usage

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

Arguments

x

matrix with any typeof. If not a matrix, it will be coerced to a matrix via as.matrix. The function allows for colnames to carry over for non-matrix objects (e.g., data.frames).

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 = ncol(x), and names = colnames(x) providing the frequency of missing values (or observed values if ov = TRUE) per column. If prop = TRUE, the values will range from 0 to 1. If prop = FALSE, the values will range from 1 to nrow(x).

See Also

is.na vecNA rowNA rowsNA

Examples

1
2
3
4
colNA(as.matrix(airquality)) # count of missing values
colNA(as.matrix(airquality), prop = TRUE) # proportion of missing values
colNA(as.matrix(airquality), ov = TRUE) # count of observed values
colNA(as.data.frame(airquality), prop = TRUE, ov = TRUE) # proportion of observed values

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

Related to colNA in quest...