Furthermore, you forget dealing with vectors in the check:
> if (1:3) print('yes') else print('no')
[1] "yes"
Warning message:
In if (1:3) print("yes") else print("no") :
the condition has length > 1 and only the first element will be used
> if (identical(TRUE, as.logical(1:3))) print('yes') else print('no')
[1] "no"
So invoking as.logical is not going to help you to test for the truth value of an "arbitrary not-necessarily-already-boolean value", only if it's already a scalar.
issue raised in #8: