我想从表dt_false
中的匹配行中减去dt
表中的值。结果是正确的,虽然我想知道为什么会发生警告?
library(data.table)
dt <- data.table(id = letters[1:15],
value = 1:15,
key = "id")
dt_false <- data.table(id = letters[6:20],
value = 6:20,
key = "id")
# matching subset
dt[dt_false, nomatch=0]
# use nomatch = 0 to include only the matches
# use i.v1 to reference v1 from the i component
dt[dt_false, nomatch=0, value := value - i.value, ]
Warning message:
In `[.data.table`(dt, dt_false, `:=`(value, value - i.value), nomatch = 0) :
Supplied 10 items to be assigned to 15 items of column 'value' (recycled leaving remainder of 5 items).