Learn R Programming

quest (version 0.2.0)

rowsNA: Frequency of Multiple Sets of Missing Values by Row

Description

rowsNA computes the frequency of missing values for multiple sets of columns from a data.frame. The arguments prop and ov allow the user to specify if they want to sum or mean the missing values as well as compute the frequency of observed values rather than missing values. This function is essentially a vectorized version of rowNA that inputs and outputs a data.frame.

Usage

rowsNA(data, vrb.nm.list, prop = FALSE, ov = FALSE)

Value

data.frame with the frequency of missing values (or observed values if ov = TRUE) for each set of variables. The names are specified by

names(vrb.nm.list); if vrb.nm.list does not have any names, then the first element from vrb.nm.list[[i]] is used.

Arguments

data

data.frame of data.

vrb.nm.list

list where each element is a character vector of colnames in data specifying the variables for that set of columns. The names of vrb.nm.list will be the colnames of the return object.

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).

See Also

rowNA colNA vecNA is.na

Examples

Run this code
vrb_list <- lapply(X = c("O","C","E","A","N"), FUN = function(chr) {
   tmp <- grepl(pattern = chr, x = names(psych::bfi))
   names(psych::bfi)[tmp]
})
rowsNA(data = psych::bfi,
   vrb.nm.list = vrb_list) # names set to first elements in `vrb.nm.list`[[i]]
names(vrb_list) <- paste0(c("O","C","E","A","N"), "_m")
rowsNA(data = psych::bfi, vrb.nm.list = vrb_list) # names set to names(`vrb.nm.list`)

Run the code above in your browser using DataLab