Skip to content
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

filter DT using max() in i: group_id==max(group_id) #858

Closed
jangorecki opened this issue Oct 6, 2014 · 1 comment
Closed

filter DT using max() in i: group_id==max(group_id) #858

jangorecki opened this issue Oct 6, 2014 · 1 comment
Assignees
Milestone

Comments

@jangorecki
Copy link
Member

Use case to pick only observations related to last group
Take following dt:

dt <- data.table(group_id = c(1,1,1,2,2,2,3,3,3), val = rnorm(9))

This works in 1.9.3 but doesn't work in 1.9.4:

dt[group_id == max(group_id)]

As for now to achieve the following in 1.9.4 I need to do:

dt[group_id == max(dt$group_id)]
# or
dt[,.SD][,max_group_id:=max(group_id)][group_id == max_group_id][,max_group_id:=NULL][]
# [,.SD] - prevent write dt by reference

Is there any recommended (in terms of future support) way of achieve that?

@jangorecki jangorecki changed the title filter DT using i: group_id==max(group_id) filter DT using max() in i: group_id==max(group_id) Oct 6, 2014
@arunsrinivasan arunsrinivasan added this to the v1.9.6 milestone Oct 7, 2014
@arunsrinivasan
Copy link
Member

Thanks @jangorecki. For now you can use options(datatable.auto.index=FALSE) to turn the feature off, and things should work normally, until we fix this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants