assertthat icon indicating copy to clipboard operation
assertthat copied to clipboard

is.flag(NA) returns TRUE

Open joethorley opened this issue 10 years ago • 4 comments

is.count(NA) returns FALSE is.number(NA) returns FALSE is.string(NA) returns FALSE

but is.flag(NA) returns TRUE

this seems inconsistent to me and is annoying because it then requires use of noNA()

Example code

is.flag(NA) is.count(NA) is.number(NA) is.string(NA)

on version 0.1

joethorley avatar Feb 13 '14 22:02 joethorley

That's because NA is logical: cf. NA_character_, NA_real_, NA_integer_.

hadley avatar Feb 15 '14 16:02 hadley

I didn't know that!

However I would still like a function that confirms a variable has the value TRUE or FALSE versus any other possible value.

Is it possible to add such a function to assert_that?

Say something like:

is.indicator is.TF

joethorley avatar Feb 17 '14 18:02 joethorley

What about is.flag(x, naok = FALSE) ? Or is.flag(x, nona = TRUE)

hadley avatar Feb 17 '14 19:02 hadley

Sweet!

My vote is for is.flag(x, nona = TRUE) (for consistency with noNA)

joethorley avatar Feb 17 '14 19:02 joethorley