Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ unit = "s")

4. If `.SD` is returned as-is during grouping, it is now unlocked for downstream usage, part of [#4159](https://github.com/Rdatatable/data.table/issues/4159). Thanks also to @mllg for detecting a problem with the initial fix here during the dev release [#4173](https://github.com/Rdatatable/data.table/issues/4173).

5. `GForce` is deactivated for `[[` on non-atomic input, part of [#4159](https://github.com/Rdatatable/data.table/issues/4159).
5. `GForce` is deactivated for `[[` on non-atomic input, part of [#4159](https://github.com/Rdatatable/data.table/issues/4159). Thanks @hongyuanjia and @ColeMiller1 for helping debug an issue in dev with the original fix before release, [#4612](https://github.com/Rdatatable/data.table/issues/4612).

6. `all.equal(DT, y)` no longer errors when `y` is not a data.table, [#4042](https://github.com/Rdatatable/data.table/issues/4042). Thanks to @d-sci for reporting and the PR.

Expand Down
6 changes: 3 additions & 3 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -1539,10 +1539,10 @@ replace_dot_alias = function(e) {
jvnames = sdvars
}
} else if (length(as.character(jsub[[1L]])) == 1L) { # Else expect problems with <jsub[[1L]] == >
# g[[ only applies to atomic input, for now, was causing #4159
# g[[ only applies to atomic input, for now, was causing #4159. be sure to eval with enclos=parent.frame() for #4612
subopt = length(jsub) == 3L &&
(jsub[[1L]] == "[" ||
(jsub[[1L]] == "[[" && is.name(jsub[[2L]]) && eval(call('is.atomic', jsub[[2L]]), envir = x))) &&
(jsub[[1L]] == "[[" && is.name(jsub[[2L]]) && eval(call('is.atomic', jsub[[2L]]), x, parent.frame()))) &&
(is.numeric(jsub[[3L]]) || jsub[[3L]] == ".N")
headopt = jsub[[1L]] == "head" || jsub[[1L]] == "tail"
firstopt = jsub[[1L]] == "first" || jsub[[1L]] == "last" # fix for #2030
Expand Down Expand Up @@ -2261,7 +2261,7 @@ is.na.data.table = function (x) {
Ops.data.table = function(e1, e2 = NULL)
{
ans = NextMethod()
if (cedta() && is.data.frame(ans)) ans = as.data.table(ans)
if (cedta() && is.data.frame(ans)) ans = as.data.table(ans)
else if (is.matrix(ans)) colnames(ans) = copy(colnames(ans))
ans
}
Expand Down
7 changes: 7 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -8088,6 +8088,13 @@ test(1581.17, DT[ , as.list(l[[f1]])[[f2]], by=c("f1","f2")],
data.table(f1 = c("a", "b"), f2 = c("x", "y"), V1 = c("ax", "by")))
test(1581.18, DT[, v:=l[[f1]][f2], by=c("f1","f2")],
data.table(f1=c("a","b"), f2=c("x","y"), v=c("ax", "by")))
# When the object being [[ is in parent.frame(), not x,
# need eval to have enclos=parent.frame(), #4612
DT = data.table(id = c(1, 1, 2), value = c("a", "b", "c"))
DT0 = copy(DT)
fun = function (DT, tag = c("A", "B")) DT[, var := tag[[.GRP]], by = "id"]
fun(DT)
test(1581.19, DT, DT0[ , var := c('A', 'A', 'B')])

# handle NULL value correctly #1429
test(1582, uniqueN(NULL), 0L)
Expand Down