Skip to content

Commit e04e67f

Browse files
committed
fix type coercion in bmerge
1 parent 6a15f86 commit e04e67f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

R/bmerge.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
7171
stopf("Incompatible join types: %s (%s) and %s (%s). Factor columns must join to factor or character columns.", xname, xclass, iname, iclass)
7272
}
7373
if (xclass == iclass) {
74-
if (verbose) catf("%s has same type (%s) as %s. No coercion needed.\n", iname, xclass, xname)
74+
if (length(icols)>1 && class(x[[xc]])=="Date" && class(i[[ic]]=="Date")) {
75+
set(x, j=xc, value=as.double(x[[xc]]))
76+
set(i, j=ic, value=as.double(i[[ic]]))
77+
if (verbose) catf("%s and %s are both Dates. R does not guarentee a type for Date internally, hence, coercing to double.\n", iname, xname)
78+
} else {
79+
if (verbose) catf("%s has same type (%s) as %s. No coercion needed.\n", iname, xclass, xname)
80+
}
7581
next
7682
}
7783
if (xclass=="character" || iclass=="character" ||

0 commit comments

Comments
 (0)