You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is related to #7074. if_any() is now supposed to return FALSE when no inputs are provided as per #7072. This works correctly inside filter but not mutate.
iris %>%
filter(if_any(c(), \(x) x>4000)) # returns no rows as expectediris %>%
mutate(z= if_any(c(), \(x) x>4000)) # incorrectly returns all TRUE
Apologies if I misunderstood something.
The text was updated successfully, but these errors were encountered:
This unconditionally returns TRUE for empty inputs.
My proposed fix is:
if_across<-function(op, df) {
n<- nrow(df)
across_if_fn<- context_peek_bare("across_if_fn")
if (!length(df)) {
if (across_if_fn=="if_any") {
return(FALSE)
} else {
return(TRUE)
}
}
combine<-function(x, y) {
if (is_null(x)) {
y
} else {
op(x, y)
}
}
reduce(df, combine, .init=NULL)
}
The across_if_fn stores information about the type of across function we are calling. It will then returnFALSE for if_any() and TRUE for if_all(). The rest of the function is unchanged. New to this but happy to submit a PR if this solution looks alright to you. I'll also add a test case.
This is related to #7074.
if_any()
is now supposed to returnFALSE
when no inputs are provided as per #7072. This works correctly insidefilter
but notmutate
.Apologies if I misunderstood something.
The text was updated successfully, but these errors were encountered: