is_logical_vec {checkthat} | R Documentation |
Check if a Vector is a Valid Logical Vector
Description
This function checks if a given vector is a valid logical vector. A valid
logical vector is one that contains only logical values (TRUE
or
FALSE
), has a length of at least 1, and does not consist entirely of
missing values (NA
).
Usage
is_logical_vec(logical_vec)
Arguments
logical_vec |
A vector to be evaluated. |
Value
TRUE
if logical_vec
is a valid logical vector,
otherwise FALSE
.
Examples
# Check if a valid logical vector
is_logical_vec(c(TRUE, FALSE, TRUE)) # Returns TRUE
# Check if an empty vector
is_logical_vec(c()) # Returns FALSE
# Check if a vector with missing values
is_logical_vec(c(TRUE, FALSE, NA)) # Returns TRUE
is_logical_vec(c(NA, NA, NA)) # Returns FALSE
[Package checkthat version 0.1.0 Index]