-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
first() on a numeric vector with negative argument returns unexpected result #325
Comments
The issue, such as there is one, appears to only be on vectors, and not on actual xts objects: x<-c(1:4)
y<-xts(x,order.by=as.Date(x))
first(x)
# [1] 1
first(x,-1)
# [1] 3 4 # not as expected
y
# [,1]
# 1970-01-02 1
# 1970-01-03 2
# 1970-01-04 3
# 1970-01-05 4
first(y,-1)
# [,1]
# 1970-01-03 2
# 1970-01-04 3
# 1970-01-05 4
first(y,'-1 day')
# [,1]
# 1970-01-03 2
# 1970-01-04 3
# 1970-01-05 4
|
I just checked, and found that the existing tests use an input vector of 3 elements. They fail if they are lengthened to 4 elements. So this is certainly a bug. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Hi there, there seems to be changes in the way the function first treats vector when given a negative argument.
Expected behavior
previously the function first(vect, -1) will return the original vect minus the number at the first index for xts version 0.11 but now in xts 0.12 the behaviour changes. I am not sure what it is trying to do anymore
Minimal, reproducible example
this will now return c(3, 4) in xts version 0.12
seems like a bug as the result is quite unexpected ?
The text was updated successfully, but these errors were encountered: