-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Hi,
I am using a magnificent data.table package version 1.9.4. Thanks a lot for such useful software masterpiece.
In example below, data.table complains that columns o and n are of different length while I don't see a reason why they should be different.
library(data.table)
tr = data.table(k = c(0, 2, 3, 7), o = "b", key = "k")
en = data.table(k = c(1, 2, 3, 4, 5), n = c("n1", "n2", "n3", "n4", "n5"), key = "k")
tr_copy = copy(tr)
## Gives a warning about recycling and produces wrong result,
## why `o` and `n` of a different length, aren't they supposed to be equal after join?
tr_copy[en, o := n, nomatch = 0]
## Warning message: In `[.data.table`(tr_copy, en, `:=`(o, n), nomatch = 0) : Supplied 2 items to be assigned to 5 items of column 'o' (recycled leaving remainder of 1 items).
#######################################################
#######################################################
tr_copy = copy(tr)
## No error and gives correct result, seems counterintuitive
tr[en, o := n, nomatch = NA]