View source: R/quest_functions.R
| valids_test | R Documentation |
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.
valids_test(data, vrb.nm, valid, na.rm = TRUE)
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. |
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].
valid_test
revalids
revalid
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.