moodymudskipper / inops

Infix Operators for Detection, Subsetting and Replacement
GNU General Public License v3.0
40 stars 0 forks source link

add example `NA %in{}% NA` #28

Closed moodymudskipper closed 4 years ago

moodymudskipper commented 4 years ago

NA %in{}% NA is NA, consistently with ==, but might benefit from an example as its another difference with %in%.

karoliskoncevicius commented 4 years ago

I think this is added under section about "Behaviour" ? Or do you think that is not enough?

moodymudskipper commented 4 years ago

It is not as far as I can see, we have :

NA == 1
#> [1] NA

NA %in% 1
#> [1] FALSE

NA %in{}% 1
#> [1] NA

c(1, NA, 3) %in{}% 1:10
#> [1] TRUE   NA TRUE

where we never have NA on the rhs, I suggest :

NA == NA
#> [1] NA
NA %in% NA
#> [1] TRUE
NA %in{}% NA
#> [1] FALSE

The case of NA == NA is known to be puzzling to less experienced users, so I expect NA %in{}% NA not to be obvious to all.

karoliskoncevicius commented 4 years ago

Hmm. You wrote NA %in{}% NA is FALSE - however I am getting NA %in{}% NA to be NA. I thought it's just a sub-case of NA %in{}% 1

moodymudskipper commented 4 years ago

Sorry it was a typo, OK if you think it's clear enough it's fine by me.

karoliskoncevicius commented 4 years ago

Nope it's good, added it to the behaviour in pull req #29 Was just confused about if you wanted this in Examples or Behaviour. And after that - if you were really getting FALSE.