Check that x is a length-one logical vector with only allowed logical values.
Value
TRUE or FALSE indicating if x is a length-one logical vector
only containing allowed logical values.
See also
The vignette about design choices.
Other collections of checks on type and length:
all_characters(),
all_names(),
is_natural(),
is_number(),
is_zerolength()
Examples
is_logical(TRUE) # TRUE
#> [1] TRUE
is_logical(c(TRUE, TRUE)) # FALSE: incorrect length
#> [1] FALSE
is_logical(1) # FALSE: incorrect type
#> [1] FALSE
is_logical(NA) # FALSE: default 'allow_NA' is FALSE
#> [1] FALSE
is_logical(NA, allow_NA = TRUE) # TRUE
#> [1] TRUE
is_logical(NA_character_, allow_NA = TRUE) # FALSE: incorrect type
#> [1] FALSE