add .allow_na in keep and discard to prevent error with NAs in .x #1171
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #1156
Not sure I've implemented the right solution.
The error comes from the
as_predicate
function when NA is returned. The function can have.allow_na=TRUE
to account for this. But that messes with some other logic when passed all the way through - this test was set up expecting an error:keep(1:3), ~NA
I added an ifelse to keep that test passing, but it could still change behavior.
Alternatively,
.allow_na
could become an argument inkeep
, but I see it's not an exported argument anywhere else, so I was hesitant to put it in.