valids_test {quest} | R Documentation |
Test for Invalid Elements in Data
Description
Valid.test
tests whether data has any invalid elements. Valid values
are specified by valid
. Each variable is tested independently. If the
variable in data[vrb.nm]
has any values other than valid
, then
FALSE is returned for that variable; If the variable in data[vrb.nm]
only has values in valid
, then TRUE is returned for that variable.
Usage
valids_test(data, vrb.nm, valid, na.rm = TRUE)
Arguments
data |
data.frame of data. |
vrb.nm |
character vector of colnames from |
valid |
atomic vector or list vector of valid values. |
na.rm |
logical vector of length 1 specifying whether NA should be ignored from the validity test. If TRUE (default), then any NAs are treated as valid. |
Value
logical vector with length = length(vrb.nm)
and names =
vrb.nm
specifying whether all elements in each variable of
data[vrb.nm]
are valid. If FALSE, then (at least one) invalid values
are present in that variable of data[vrb.nm]
.
See Also
Examples
valids_test(data = psych::bfi, vrb.nm = names(psych::bfi)[1:25],
valid = 1:6) # return TRUE
valids_test(data = psych::bfi, vrb.nm = names(psych::bfi)[1:25],
valid = 0:5) # 6 is not present in `valid`
valids_test(data = psych::bfi, vrb.nm = names(psych::bfi)[1:25],
valid = 1:6, na.rm = FALSE) # NA is not present in `valid`
valids_test(data = ToothGrowth, vrb.nm = c("supp","dose"),
valid = list("VC", "OJ", 0.5, 1.0, 2.0)) # list vector as `valid` to allow for
# elements of different typeof