Skip to contents

This function checks whether x is exactly TRUE or exactly FALSE. It uses base::identical() to ensure strict checking of type, length, and value. Values that are missing, invalid (per is_invalid()), or not a single logical scalar always return FALSE.

Usage

is_bool_scalar(x)

Arguments

x

An R object to check.

Value

A logical scalar: TRUE if x is exactly TRUE or FALSE, otherwise FALSE.

Examples

is_bool_scalar(TRUE)                 # TRUE
#> [1] TRUE
is_bool_scalar(FALSE)                # TRUE
#> [1] TRUE
is_bool_scalar(NA)                   # FALSE
#> [1] FALSE
is_bool_scalar(c(TRUE, FALSE))       # FALSE
#> [1] FALSE
is_bool_scalar("TRUE")               # FALSE
#> [1] FALSE
is_bool_scalar(1L)                   # FALSE
#> [1] FALSE