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 ( eac6e7b73ac4e38cb394ece1473bc7b6c008a8dd) 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.
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 ( eac6e7b73ac4e38cb394ece1473bc7b6c008a8dd) for compatibility reasons withzoo
, 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 forzoo
objects is also shown.Session Info
Proposed solution:
Drop line 41-42 in index.R:
EDIT: opened up a PR.