View source: R/quest_functions.R
rowsNA | R Documentation |
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.
rowsNA(data, vrb.nm.list, prop = FALSE, ov = FALSE)
data |
data.frame of data. |
vrb.nm.list |
list where each element is a character vector of colnames
in |
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). |
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.
rowNA
colNA
vecNA
is.na
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`)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.