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

[R-Forge #5378] mult="first"|"last" changes the output type of [.data.table #340

Closed
arunsrinivasan opened this issue Jun 8, 2014 · 0 comments
Assignees
Milestone

Comments

@arunsrinivasan
Copy link
Member

Submitted by: Michele Carriero; Assigned to: Nobody; R-Forge link

Hi there!

Having a data.table dt like:

dt <- data.table(id=rep(1:2,each=2), var=rnorm(4), key="id")

I would expect the following two expression to give the same type of output

dt[.(1:2), list(var)]
#    id         var
#1:  1  0.77227701
#2:  1  1.62441284
#3:  2 -0.04178387
#4:  2  1.20609667

dt[.(1:2), list(var), mult="last"]
#         var
#1: 1.624413
#2: 1.206097

I think having the key column(s) in both expressions is more consistent. The difference is even more noticeable when not using list inside j.

dt[.(1:4), var]
# same than dt[.(1:4), list(var)] because by-without-by
dt[.(1:2), var, mult="last"]
# [1] 1.624413 1.206097

Regardless of by-without-by methodology is not be used, I think each of the queries above should return the same "type" of output.

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

2 participants