Skip to content

Commit

Permalink
update copying attributes from int to dbl
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-schwen committed Nov 26, 2024
1 parent 25eaa65 commit f0219c4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/bmerge.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,17 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
}
} else {
if (verbose) catf("Coercing integer column %s to type double for join to match type of %s.\n", iname, xname)
set(i, j=ic, value=as.double(i[[ic]]))
val = as.double(i[[ic]])
if (!is.null(attributes(i[[ic]]))) attributes(val) = attributes(i[[ic]]) # to retain Date for example; 3679
set(i, j=ic, value=val)
if (length(ic_idx)>1L) {
xc_idx = xcols[ic_idx]
for (b in which(vapply_1c(x[0L, ..xc_idx], getClass) == "integer")) {
xb = xcols[b]
val = as.double(x[[xb]])
if (!is.null(attributes(x[[xb]]))) attributes(val) = attributes(x[[xb]])
if (verbose) catf("Coercing integer column %s to type double for join to match type of %s.\n", paste0("x.", names(x)[xb]), xname)
set(x, j=xb, value=as.double(x[[xb]]))
set(x, j=xb, value=val)
}
}
}
Expand Down

0 comments on commit f0219c4

Please sign in to comment.