-
Notifications
You must be signed in to change notification settings - Fork 979
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
Operations with "by" do not dispatch to S3 methods #3533
Comments
Looks like a bug per your link (where a similar issue was fixed). In the meantime you can force data.table not to override mean (with its internal by-group-optimized gmean) and other functions with
Details https://stackoverflow.com/questions/22137591/about-gforce-in-data-table-1-9-2 and |
I think it's correct that data.table does not dispatch to S3 methods in grouping. Because S3 methods are very slow when iterated. In the very unusual cases like this where the mean of the class is not the mean of the underlying type; i.e. #3079 seems different: that's because we're missing a copyMostAttrib in gforce median. Can we close this issue as |
Although I agree with Michael's points in #3546 (comment), I do see your point. The behaviour exhibited in the reprex is a bit baffling, but to be fair is explainable via a reading of |
Another issue is that method |
@jangorecki yes, see my linked comment |
When using
by
, it appears that data.table is not able to dispatch S3 methods. The closest similar issue I could find was with this old SO one which was fixed in v1.9.6: https://stackoverflow.com/questions/33177009/s3-method-dispatch-in-data-table-when-using-by-clause. In this case, however, although it DOES maintain the class of the column being operated on, it does not dispatch the correct S3 method unless that is explicitly provided. In the reprex below,direction
is of classcircular
andmean(c(20, 350))
should give 5, not 185. This works withoutby
or when usingby
and explicitly callingcircular::mean.circular
, but not when usingby
and plain oldmean
:The text was updated successfully, but these errors were encountered: