Skip to content

Commit

Permalink
Closes #500. lapply(L, "[", Time ==3L) works as expected.
Browse files Browse the repository at this point in the history
Subset data.tables using lapply doesn't redirect to `[.data.frame` anymore.
  • Loading branch information
arunsrinivasan committed Aug 3, 2014
1 parent e54bf5b commit e0ce69a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/cedta.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ cedta = function(n=2L) {
ans = nsname == "data.table" ||
"data.table" %chin% names(getNamespaceImports(te)) ||
"data.table" %chin% tryCatch(get(".Depends",paste("package",nsname,sep=":"),inherits=FALSE),error=function(e)NULL) ||
(nsname == "utils" && exists("debugger.look",parent.frame(n+1L))) ||
(nsname == "utils" && exists("debugger.look",parent.frame(n+1L))) ||
(nsname == "base" && all(c("FUN", "X") %in% ls(parent.frame(n))) ) || # lapply
nsname %chin% cedta.override ||
identical(TRUE, tryCatch(get(".datatable.aware",asNamespace(nsname),inherits=FALSE),error=function(e)NULL))
if (!ans && getOption("datatable.verbose"))
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ We moved from R-Forge to GitHub on 9 June 2014, including history.
43. Segfault on joins of the form X[Y, c(..), by=.EACHI] is now fixed. Closes [#744](https://github.com/Rdatatable/data.table/issues/743). Thanks to @nigmastar (Michele Carriero) for the excellent minimal example.
44. Subset on data.table using `lapply` of the form `lapply(L, "[", Time == 3L)` works now without error due to "[.data.frame" redirection. Closes [#500](https://github.com/Rdatatable/data.table/issues/500). Thanks to Garrett See for reporting.
#### NOTES
1. Reminder: using `rolltolast` still works but since v1.9.2 now issues the following warning:
Expand Down
4 changes: 4 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -4966,6 +4966,10 @@ sample <- c("A", "B")
test(1360.1, dt[sample, c(.N), by = .EACHI], dt[sample, list(V1=.N), by=.EACHI])
test(1360.2, copy(dt)[sample, N := c(.N), by = .EACHI], copy(dt)[sample, N := .N, by = .EACHI])

# Fix for #500 - `lapply` call shouldn't redirect to `[.data.frame`.
L <- list(data.table(BOD), data.table(BOD))
test(1361, lapply(L, "[", Time==3L), list(L[[1L]][Time == 3L], L[[2L]][Time == 3L]))

##########################


Expand Down

0 comments on commit e0ce69a

Please sign in to comment.