NA is a boolean?
Issue #8
resolved
Boy, did I enjoy finding this package! I felt stupid when writing my own version of is_a_bool
(https://github.com/ropensci/beautier/blob/master/R/is_one_bool.R#L15) and was relieved to call assertive
instead of maintaining my handcrafted functions.
A showstopper to do so, however, is this:
assertive::assert_is_a_bool(NA)
I expect a boolean to be either TRUE or FALSE; NA is not among the set of valid booleans. Yet, I see in the documentation that classifying an NA as a Boolean appears to be intentional.
Is it the intention to classify NA as a boolean?
- If yes, I hope the reasoning for this will be added to the documentation. I will -sadly- have to use my own version of
is_a_bool
:-( - If no, I hope NA will be classified as not being a boolean and I can look forward to use assertive’s next version
Whatever the case, I am happy to see this package exists. Keep up the good work
Comments (3)
-
repo owner -
repo owner - changed status to resolved
The behavior is intentional, and there is an alternative function, so closing this.
-
reporter It appears I underestimated the awesomeness of your work
- Log in to comment
@richelbilderbeek
This is the intended behavior since
NA
is logical. You can see this usingclass(NA)
.After creating the function I realized that it's a fairly common thing to want to check for a value being
TRUE
orFALSE
in if conditions, so assertive.code also hasis_if_condition()
which does what you want. Seehttps://www.rdocumentation.org/packages/assertive.code/topics/assert_is_if_condition