Skip to content

.SD ignores locally updated vectors in j #7431

Description

@jan-swissre

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")))]

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions