I would expect both expressions give the same result.
Filtering in i is irrelevant, I have kept it to reflect my use case.
data.table(a = 1:3, b = 1:3, d = 1:3
)[a %in% 1:2, {
b[d == 2L] <- 0L
.SD
}]
# a b d
#1: 1 1 1
#2: 2 2 2
data.table(a = 1:3, b = 1:3, d = 1:3
)[a %in% 1:2, {
b[d == 2L] <- 0L
.(a, b, d)
}]
# a b d
#1: 1 1 1
#2: 2 0 2
1.17.0
workaround for now:
data.table::data.table(a = 1:3, b = 1:3, d = 1:3
)[a %in% 1:2, {
b[d == 2L] <- 0L
.SD
}, env = list(.SD = as.list(c("a","b","d")))]
I would expect both expressions give the same result.
Filtering in
iis irrelevant, I have kept it to reflect my use case.1.17.0
workaround for now: