Skip to content

Commit f477fac

Browse files
authored
fixes R-devel foverlaps failures due to c.POSIXct change (#4428)
1 parent df93c3d commit f477fac

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ unit = "s")
147147

148148
7. Added more explanation/examples to `?data.table` for how to use `.BY`, [#1363](https://github.com/Rdatatable/data.table/issues/1363).
149149

150+
8. Change of `c.POSIXct` method planned for R 4.1.0 impacted `foverlaps` function that could raise `'origin' must be supplied` error. Fix for planned change has been provided in [#4428](https://github.com/Rdatatable/data.table/pull/4428).
151+
150152

151153
# data.table [v1.12.8](https://github.com/Rdatatable/data.table/milestone/15?closed=1) (09 Dec 2019)
152154

R/foverlaps.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ foverlaps = function(x, y, by.x=if (!is.null(key(x))) key(x) else key(y), by.y=k
109109
setattr(icall, 'names', icols)
110110
mcall = make_call(mcols, quote(c))
111111
if (type %chin% c("within", "any")) {
112+
if (isposix) mcall[[2L]] = call("unclass", mcall[[2L]]) # fix for R-devel change in c.POSIXct
112113
mcall[[3L]] = substitute(
113114
# datetimes before 1970-01-01 are represented as -ve numerics, #3349
114115
if (isposix) unclass(val)*(1L + sign(unclass(val))*dt_eps())
@@ -128,7 +129,7 @@ foverlaps = function(x, y, by.x=if (!is.null(key(x))) key(x) else key(y), by.y=k
128129
within =, equal = yintervals)
129130
call = construct(head(ynames, -2L), uycols, type)
130131
if (verbose) {last.started.at=proc.time();cat("unique() + setkey() operations done in ...");flush.console()}
131-
uy = unique(y[, eval(call)])
132+
uy = unique(y[, eval(call)]) # this started to fail from R 4.1 due to c(POSIXct, numeric)
132133
setkey(uy)[, `:=`(lookup = list(list(integer(0L))), type_lookup = list(list(integer(0L))), count=0L, type_count=0L)]
133134
if (verbose) {cat(timetaken(last.started.at),"\n"); flush.console()}
134135
matches = function(ii, xx, del, ...) {

0 commit comments

Comments
 (0)