-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
unique(.SD) makes the lock on data.table:
library(data.table)
data.table(a=c(1,1,2))[, unique(.SD)][, b := 5]
# Error in `[.data.table`(data.table(a = c(1, 1, 2))[, unique(.SD)], , `:=`(b, :
# .SD is locked. Using := in .SD's j is reserved for possible future use; a tortuously flexible way to modify by group. Use := in j directly to modify by group by reference.While this working
data.table(a=c(1,1,2))[, unique(.SD)][, copy(.SD)][, b := 5]
# a b
#1: 1 5
#2: 2 5As the unique(.SD) is not a by reference operation, such := should work IMO.