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
Bug in grouping external variables - related to #495. #875
Comments
Hold on. I would say the first answer is incorrect and the second one is correct. Imagine if |
I think the right answer is debatable. I'd argue that since it's a grouping operation, the variable referred to should be grouped as well. But I can see the other side of this argument as well. In this case, it should end in an error (if the first one is correct), as it does (for mean). More and more, I'm leaning towards your line of thinking though. |
Well, the way I see it, the grouping simply divides up the data.table into pieces to do various (j-expression) operations on. When you refer to the column of a data.table in a group, it's obvious that you want the column for that piece of the data.table. But when you're referring to some external object, there is no reason why it should also be subdivided into pieces just because it happens to be inside the j-expression - it's not part of the data.table (and additionally, from technical point of view is only divisible if and only if it has the exact correct type and size). |
I expect mean(z) to give the same as mean(z)[1], i.e. a one element vector containing the mean of z.
|
Yes but this once again is due to the same issue - providing a variable not in the data.table in |
This bug is related to #495.
Basically
mean
is computed on entirez
in the second case (wheremean
gets optimised tofastmean
internally). This is most likely because.SD
doesn't have this variable in it. So it comes back to #495.For the same reason, say calculating variance or standard deviation won't work, even if optimise value if
Inf
(because GForce isn't implemented for those functions).For now, using external variables for grouping has a bug. This observation came from this SO post. Thanks to drstevok.
The text was updated successfully, but these errors were encountered: