对连接的data.table子集进行计算会引发警告,但结果是否正确?

时间:2015-05-13 07:00:04

标签: r join data.table

我想从表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).

0 个答案:

没有答案