Skip to content

Commit f0219c4

Browse files
committed
update copying attributes from int to dbl
1 parent 25eaa65 commit f0219c4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

R/bmerge.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,17 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
139139
}
140140
} else {
141141
if (verbose) catf("Coercing integer column %s to type double for join to match type of %s.\n", iname, xname)
142-
set(i, j=ic, value=as.double(i[[ic]]))
142+
val = as.double(i[[ic]])
143+
if (!is.null(attributes(i[[ic]]))) attributes(val) = attributes(i[[ic]]) # to retain Date for example; 3679
144+
set(i, j=ic, value=val)
143145
if (length(ic_idx)>1L) {
144146
xc_idx = xcols[ic_idx]
145147
for (b in which(vapply_1c(x[0L, ..xc_idx], getClass) == "integer")) {
146148
xb = xcols[b]
149+
val = as.double(x[[xb]])
150+
if (!is.null(attributes(x[[xb]]))) attributes(val) = attributes(x[[xb]])
147151
if (verbose) catf("Coercing integer column %s to type double for join to match type of %s.\n", paste0("x.", names(x)[xb]), xname)
148-
set(x, j=xb, value=as.double(x[[xb]]))
152+
set(x, j=xb, value=val)
149153
}
150154
}
151155
}

0 commit comments

Comments
 (0)