-
Notifications
You must be signed in to change notification settings - Fork 993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
last() no longer dispatches if data.table::last masks xts::last #1347
Comments
Joshua, yes that seems like a better fix to me too. |
Would you like me to submit a PR? |
If you can, sure :-). Else I / @jangorecki (?) can take care of it. |
Maybe something like this at the beginning of if (inherits(x, "xts") && "package:xts" %in% search())
xts::last(x, ...) |
@jangorecki Joshua has already provided the fix (to use |
data.table::last is intended to work with xts::last, which is a S3 generic. e011351 appears to have caused a regression that prevents xts::last from dispatching. Revert e011351, but keep the is.data.frame check on the happy path, so it will be fast for data.table objects. Return xts::last if xts is on the search path. Otherwise, return tail(x, ...) instead of throwing an error (the previous behavior).
Fixed now @joshuaulrich, please verify. |
@arunsrinivasan, that's essentially what I had in my commits, so it looks good to me! You were able to get to the unit test before I was... I got "distracted" by my job. :) Thanks! |
sorry, dint see your commits... 👍 |
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 causexts::last.default
to be used any time xts is on the search path, andxts::last.default
is slower thandata.table::last
for vectors, lists, data.frame, or data.table. I think a better solution would have been to replace the call tostop
with a call totail(x, ...)
. Thoughts?The text was updated successfully, but these errors were encountered: