You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require(data.table)
a = data.table(start = 1:5, end = 2:6, c2 = rnorm(100), c2 = rnorm(100))
b = data.table(start = 1:5, end = 2:6, c3 = rnorm(10))
setkey(a, start, end)
setkey(b, start, end)
foverlaps(a, b)
Error is Error in setcolorder(ans, c(xcols1, ycols, xcols2)) : neworder is length 6 but x has 7 columns.
I think the problem is that foverlap checks
if (anyDuplicated(by.x) || anyDuplicated(by.y))
stop("Duplicate columns are not allowed in overlap joins. This may change in the future.")
whereas merge checks
if (any(duplicated(names(x)))) stop("x has some duplicated column name(s): ",paste(names(x)[duplicated(names(x))],collapse=","),". Please remove or rename the duplicate(s) and try again.")
if (any(duplicated(names(y)))) stop("y has some duplicated column name(s): ",paste(names(y)[duplicated(names(y))],collapse=","),". Please remove or rename the duplicate(s) and try again.")
Foverlaps only throws an error when by.x or by.y have duplicates, but will throw an error if any of the columns in x are duplicated (i.e. regardless of whether or not they are in by.x)
The text was updated successfully, but these errors were encountered:
The error only seems to happen if x has duplicated column names, duplicates in y don't seem to cause the same problem. The following does not throw any errors.
a = data.table(start = 1:5, end = 2:6, c2 = rnorm(100), c4 = rnorm(100))
b = data.table(start = 1:5, end = 2:6, c3 = rnorm(10), c3 = rnorm(10))
setkey(a, start, end)
setkey(b, start, end)
foverlaps(a, b)
Thanks for reporting. Join is performed correctly, just reordering columns in the results failed to handle duplicates. Workarounds of setcolorder (in multiple places here) would likely results into more issues in future, so meaningful error looks to be better solution here.
Code to reproduce:
Error is
Error in setcolorder(ans, c(xcols1, ycols, xcols2)) : neworder is length 6 but x has 7 columns.
I think the problem is that foverlap checks
whereas merge checks
Foverlaps only throws an error when by.x or by.y have duplicates, but will throw an error if any of the columns in x are duplicated (i.e. regardless of whether or not they are in by.x)
The text was updated successfully, but these errors were encountered: