Check if the argument is one boolean

is_one_bool(x)

Arguments

x

the argument to be tested to be boolean

Author

Richèl J.C. Bilderbeek

Examples

# TRUE
is_one_bool(TRUE)
#> [1] TRUE
is_one_bool(FALSE)
#> [1] TRUE

# FALSE
is_one_bool(NULL)
#> [1] FALSE
#> Cause of failure:  x is not of class 'logical'; it has class 'NULL'. 
is_one_bool(NA)
#> [1] FALSE
#> Cause of failure:  x is NA. 
is_one_bool(c())
#> [1] FALSE
#> Cause of failure:  x is not of class 'logical'; it has class 'NULL'. 
is_one_bool("nonsense")
#> [1] FALSE
#> Cause of failure:  x is not of class 'logical'; it has class 'character'. 
is_one_bool(is_one_bool)
#> [1] FALSE
#> Cause of failure:  x is not of class 'logical'; it has class 'closure function'. 
is_one_bool(c(TRUE, FALSE))
#> [1] FALSE
#> Cause of failure:  x has length 2, not 1.