Skip to contents

are_lgl_ish() is a vectorized predicate function that checks whether each element of its input can be safely coerced to a logical vector.

is_lgl_ish() is a scalar predicate function that checks if all elements of its input can be safely coerced to a logical vector.

Usage

are_lgl_ish(x, ...)

is_lgl_ish(x, ...)

# Default S3 method
are_lgl_ish(x, ..., depth = 1)

Arguments

x

The object to check.

...

Arguments passed to methods.

depth

(length-1 integer) Current recursion depth. Do not manually set this parameter.

Value

are_lgl_ish() returns a logical vector with the same length as the input. is_lgl_ish() returns a length-1 logical (TRUE or FALSE) for the entire vector.

Examples

are_lgl_ish(c(TRUE, FALSE, NA))
#> [1] TRUE TRUE TRUE
is_lgl_ish(c(TRUE, FALSE, NA))
#> [1] TRUE

are_lgl_ish(c(1, 0, 1.0, NA))
#> [1] TRUE TRUE TRUE TRUE
is_lgl_ish(c(1, 0, 1.0, NA))
#> [1] TRUE

are_lgl_ish(c("T", "F", "TRUE", "FALSE", "true", "false", "1", "0"))
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
is_lgl_ish(c("T", "F", "TRUE", "FALSE", "true", "false", "1", "0"))
#> [1] TRUE

are_lgl_ish(c("T", "F", "a", "1.1"))
#> [1]  TRUE  TRUE FALSE  TRUE
is_lgl_ish(c("T", "F", "a", "1.1"))
#> [1] FALSE

are_lgl_ish(factor(c("T", "a")))
#> [1]  TRUE FALSE
is_lgl_ish(factor(c("T", "a")))
#> [1] FALSE

are_lgl_ish(list(TRUE, 0, "F", "a"))
#> [1]  TRUE  TRUE  TRUE FALSE
is_lgl_ish(list(TRUE, 0, "F", "a"))
#> [1] FALSE