purrr icon indicating copy to clipboard operation
purrr copied to clipboard

every() depends on vector order when NA is present

Open alberto-dellera opened this issue 4 years ago • 1 comments

library(purrr)

every( c(FALSE, NA), identity )
#> [1] FALSE
every( c(NA, FALSE), identity )
#> [1] NA

IMHO it should return the same and be consistent with &&:

FALSE && NA
#> [1] FALSE
NA && FALSE
#> [1] FALSE

alberto-dellera avatar Mar 06 '20 15:03 alberto-dellera

I think your analysis is correct. Especially since some() is implemented using || so it has the same behaviour as that operator. It would make a lot of sense for every() to behave like &&. This would be a behaviour change though :/

lionel- avatar Aug 05 '20 09:08 lionel-

While this will change behaviour, I wouldn't characterise it as a breaking change; more that it's fixing a bug.

hadley avatar Aug 24 '22 14:08 hadley