-
Notifications
You must be signed in to change notification settings - Fork 991
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
Why doesn't DT[v1==max(v1), , by=v2]
work?
#1246
Comments
Why not just |
I assume it throws an error because you are not quering any data = lack of |
@jangorecki I see. I asked this question not for a solution, because I obviously have one already. Can I suggest this way of querying ( @DavidArenburg Thanks for suggesting. But IMHO, the proposed way is much more intuitive and general. I used Lastly, I think the code is intuitive enough such that a replicable example is not necessary. A replicable example may not be general enough and thus lead to ad hoc solutions to the particular example, rather than a general situation. |
Would be good then to isolate FR. What I understand you simply forms FR to |
@ywhuofu how would you read For reference, this is the current reading: "take |
@eantonya simply "take DT, apply |
@ywhuofu that's not enough. Any reading paradigm you come up with has to include |
I agree that "apply |
@franknarf1 @eantonya , by the same logic, why would |
@ywhuofu It does make sense as "do The general syntax is "subset to
Your proposed reading of "do |
@franknarf1 Okay, your points are well taken. What I am proposing is simply "subset by group". Moreover, how do I read In general, my questions concerns following general situation. I intend accomplish something like (I know following code doesn't work)
without having to go through
? In any case, thank you for your responses. I am an end user and a fan of data.table, but has no clue on whatsoever under the hood. |
@ywhuofu I'm also an end user. The problem I have with your proposed syntax is what I said initially:
though I haven't thought through all the problems that might raise. Anyway, the discussion at that FR may interest you: #788 |
@ywhuofu (morally) the default value of The standard (most readable) syntax to accomplish what you wrote is:
with the faster version of it being: |
@franknarf1 @eantonya , thank you very much for going through this with me. I've learned a lot. I will close this issue. |
When I try
DT[v1==max(v1), , by=v2]
. It throws me an error.Currently, I am doing something like:
DT[, v1_max:=max(v1), by=v2][v1==v1_max][, v1_max:=NULL]
Note
max()
is used for illustration. It could be any function.The text was updated successfully, but these errors were encountered: