Skip to contents

check_logical() checks if the input lgl is a logical value. If lgl is not logical, it returns a default value provided by the user.

Usage

check_logical(lgl, default)

Arguments

lgl

The input value to be checked. It can be of any type.

default

The default logical value to return if lgl is not logical. This should be either TRUE or FALSE.

Value

A logical value. Returns lgl if it is logical; otherwise, returns the isTRUE(default) value. That is, it returns TRUE if default = TRUE and FALSE otherwise.

Examples

check_logical(TRUE, FALSE)
#> [1] TRUE
check_logical("Not a logical", TRUE)
#> [1] TRUE
check_logical(5, FALSE)
#> [1] FALSE
check_logical(FALSE, TRUE)
#> [1] FALSE