You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
xts:::index.xts() returns integer(0) instead of .POSIXct(character(0)) for a zero length xts object ordered by POSIXct values.
Searched for similar issues before opening this one, but didn't find this exact problem.
Noticed this inconsistency was intentionally introduced ( eac6e7b) for compatibility reasons with zoo, but as far as I can tell, zoo must in the meantime has changed its behaviour.
Minimal, reproducible example
Example shows inconsistent behaviour for POSIXct and consistent behaviour for Date.
The behaviour for zoo objects is also shown.
library(xts)
timeXts<- xts(1, as.POSIXct("2000-01-01"))
dateXts<- xts(1, as.Date("2000-01-01"))
xts:::index.xts(timeXts)
# [1] "2000-01-01 CET"xts:::index.xts(timeXts[0,])
# integer(0)xts:::index.xts(dateXts)
# [1] "2000-01-01"xts:::index.xts(dateXts[0,])
# Date of length 0
library(zoo)
timeZoo<- zoo(1, as.POSIXct("2000-01-01"))
dateZoo<- zoo(1, as.Date("2000-01-01"))
zoo::index(timeZoo)
# [1] "2000-01-01 CET"zoo::index(timeZoo[0,])
# POSIXct of length 0zoo::index(dateZoo)
# [1] "2000-01-01"zoo::index(dateZoo[0,])
# Date of length 0
Description
xts:::index.xts()
returnsinteger(0)
instead of.POSIXct(character(0))
for a zero lengthxts
object ordered byPOSIXct
values.Searched for similar issues before opening this one, but didn't find this exact problem.
Noticed this inconsistency was intentionally introduced ( eac6e7b) for compatibility reasons with
zoo
, but as far as I can tell,zoo
must in the meantime has changed its behaviour.Minimal, reproducible example
Example shows inconsistent behaviour for
POSIXct
and consistent behaviour forDate
.The behaviour for
zoo
objects is also shown.Session Info
Proposed solution:
Drop line 41-42 in index.R:
EDIT: opened up a PR.
The text was updated successfully, but these errors were encountered: