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
Segfault caused by min function in summarise function #1481
Comments
@hadley should I also throw a warning like R does ? |
I don't think so - R isn't consistent anyway compare |
+/- Inf is not always expected; sorry I'm not good enough w/c++ to write a sol'n but I can give an example: min(1[-)],na.rm=TRUE)
[1] Inf
Warning message:
In min(1[-1], na.rm = TRUE) :
no non-missing arguments to min; returning Inf
> min("a"[-1],na.rm=TRUE)
[1] NA
Warning message:
In min("a"[-1], na.rm = TRUE) : no non-missing arguments, returning NA But in dplyr with the current commit: > summarise(data.frame(A=1[-1]), Min=min(na.rm=TRUE))
Min
1 Inf
Warning message:
In min(na.rm = TRUE) : no non-missing arguments to min; returning Inf
> summarise(data.frame(A="a"[-1]), Min=min(na.rm=TRUE))
Min
1 Inf
Warning message:
In min(na.rm = TRUE) : no non-missing arguments to min; returning Inf |
For the record I think R is idiosyncratic here. I kind of wish min(numeric()) returned numeric(0), and so on for other types. Oh well. |
I think the contract for |
Yes, that's what I meant by idiosyncratic. Mathematically, the minimum of a set S is the intersection of S with infimum(S), a.k.a. the smallest value in the set. Mathematica, Matlab, etc. return min(empty set) = empty set, consistent with that definition, R does not. --Sorry, this is an R issue really, not a dplyr one. Not the best place to discuss it! |
When apply min function on summarizing an empty data.frame, it would lead to segfault.
more details see this StackOverflow Question
The text was updated successfully, but these errors were encountered: