New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"some" works oddly with NA #514

ISPritchin opened this Issue Jun 11, 2018 · 2 comments


None yet
2 participants
Copy link

ISPritchin commented Jun 11, 2018

Documentation "Do some elements of a list satisfy a predicate?"
Why this function returns NA in this case?

some(c(NA, -2), ~ .x < 0)  #NA

I read the source code.
It follows from the code that if NA is before the satisfying element of the vector, NA will be returned,
However, -2 satisfies the condition.


some(c(-2, NA), ~ .x < 0)  #TRUE

This comment has been minimized.

Copy link

batpigandme commented Jun 11, 2018

[it seems as though it returns NA if the first element is NA, or if the condition isn't satisfied and contains NA]

some(c(NA, -2), ~ .x < 0)
#> [1] NA
some(c(-2, NA), ~ .x < 0)
#> [1] TRUE
some(c("NA", -2), ~ .x < 0)
#> [1] TRUE
some(c("NA", NA), ~ .x < 0)
#> [1] NA
some(c(2, NA), ~ .x < 0)
#> [1] NA

Created on 2018-06-11 by the reprex package (v0.2.0).


This comment has been minimized.

Copy link

ISPritchin commented Jun 11, 2018

Expected behavior:

  1. If the condition is TRUE for at least one element, return TRUE.
  2. If FALSE for all and has NA - return NA (We do not have information about NA)
  3. Otherwise - FALSE

@ISPritchin ISPritchin changed the title some "some" works oddly with NA Jun 13, 2018

daniel-barnett added a commit to daniel-barnett/purrr that referenced this issue Jul 10, 2018

@hadley hadley closed this in cd4f054 Sep 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment