Skip to content

last() no longer dispatches if data.table::last masks xts::last #1347

@joshuaulrich

Description

@joshuaulrich
library(xts)
library(data.table)
last(.xts(1:3,1:3))
# [1] 3
# but should be (was in 1.9.4):
#                     [,1]
#1969-12-31 18:00:03    3

It looks like the change in e011351 is the cause, and it seems like it's just an error in the if statement (|| should be &&).

But changing the || to && will cause xts::last.default to be used any time xts is on the search path, and xts::last.default is slower than data.table::last for vectors, lists, data.frame, or data.table. I think a better solution would have been to replace the call to stop with a call to tail(x, ...). Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions