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 #5585] DT[, list(list(.)), by=.] returns wrong results in R-3.1.0. #481

Closed
arunsrinivasan opened this issue Jun 8, 2014 · 1 comment
Assignees
Milestone

Comments

@arunsrinivasan
Copy link
Member

Submitted by: Arun ; Assigned to: Nobody; R-Forge link

require(data.table)
DT <- data.table(x=c(1,2,2,3,3,3), y=10:15)
DT[, print(list(list(.I))), by=x] ## prints fine.
# [[1]]
# [[1]][[1]]
# [1] 1
# 
# [[1]]
# [[1]][[1]]
# [1] 2 3
# 
# [[1]]
# [[1]][[1]]
# [1] 4 5 6
# 
# Empty data.table (0 rows) of 1 col: x

DT[, list(list(.I)), by=x] ## all points to last grouping variable
#    x    V1
#1: 1 4,5,6
#2: 2 4,5,6
#3: 3 4,5,6

The issue goes away if . is wrapped with I(.) or any other function for that matter.

## works fine.
DT[, list(list(I(.I))), by=x]
DT[, list(list(sum(y))), by=x]
@arunsrinivasan arunsrinivasan changed the title [R-Forge #5585] DT[, list(list(.)), by=.] returns wrong results in R-3.1.0. [R-Forge #5585] DT[, list(list(.)), by=.] returns wrong results in R-3.1.0. Jun 9, 2014
@arunsrinivasan arunsrinivasan changed the title [R-Forge #5585] DT[, list(list(.)), by=.] returns wrong results in R-3.1.0. [R-Forge #5585] DT[, list(list(.)), by=.] returns wrong results in R-3.1.0. Jun 9, 2014
@arunsrinivasan arunsrinivasan added this to the v1.9.4 milestone Jun 19, 2014
@arunsrinivasan arunsrinivasan self-assigned this Jun 25, 2014
@arunsrinivasan
Copy link
Member Author

update: fixed in commit 1311, 5e2ced0. All good!

Just realised that this only fixes this case, but not DT[, z := list(list(y)), by=x]. Will reopen and fix soon.

mattdowle added a commit that referenced this issue Oct 18, 2016
…ing with .BY and list columns. Removed switch on R 3.1.0. Added simpler code to central memrecycle. Turned back on test 1691. All tests now pass R 3.0.0 (pre R 3.1.0) and R 3.3.1. Closes #1270. Simplifies #481.
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

1 participant