joshuaulrich / xts

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.
http://joshuaulrich.github.io/xts/
GNU General Public License v2.0
219 stars 70 forks source link

Test failure in R-devel due to change in match() behavior #373

Closed joshuaulrich closed 1 year ago

joshuaulrich commented 1 year ago

In an email from Kurt Hornik:

Josh,

This is from recent changes in R-devel which change match() to transform classed x or table via as.character().

The problem seems to be in

  window_dbg <- function(x, index. = index(x), start, end)
  {
    start <- xts:::.toPOSIXct(start, tzone(x))
    end <- xts:::.toPOSIXct(end, tzone(x))
    index. <- as.POSIXct(index., tz=tzone(x))
    all.indexes <- .index(x)
    in.index <- all.indexes %in% index.
    matches <- (in.index & all.indexes >= start & all.indexes <= end)
    x[matches,]
  }

where with

  start <- base + 12*DAY
  end <- base + 12*DAY
  bin <- window(x, start = start, end = end)
  reg <- window_dbg(x, start = start, end = end)

you get

Browse[2]> class(index.)
[1] "POSIXct" "POSIXt"
Browse[2]> class(.index(x))
[1] "numeric"

I think you could try

in.index <- all.indexes %in% unclass(index.)

(or as.numeric() instead of unclass()) to get back the old behavior?

Hth -k