-
-
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
Problem with indexing after change of indexing type #311
Comments
Thanks for the report! I see that you're using xts_0.11-2. Can you please try the current development version 0.12.0 and report back? |
Joshua, I tried as you said other attached packages:
[1] xts_0.12-0 zoo_1.8-6 but still the same problem... > test2 <- convertIndex(test, "Date")
> tclass(test2)
[1] "Date"
> test2["2014-01-01"]
[,1]
2014-01-01 0.5057137
> index(test2["2014-01-01"])
[1] "2014-01-01"
> test2[index(test2["2014-01-01"])] # What???!!! Empty!!!
[,1] |
Thanks for checking! I investigated and found the cause is that all.equal(.index(test), .index(test2), check.attributes=FALSE)
# [1] TRUE We've discussed internally in the past whether or not changing the |
Joshua, indeed that's what I suspected. Thanks for looking into it. IMHO, I think this choice is very misleading and prone to errors. I don't see the point of changing the type of index without actually changing the indices. So if you ask me, I would either totally change the indices or deprecate this wrapper. But that's my opinion. Thanks! |
I'm going to make this change and do reverse dependency checks to see what, if anything, breaks. I think the only time the actual underlying index values would change is when the 'tclass' changes from one with a timezone to one without a timezone. Part of the change will be a warning any time the 'tclass' changes from one with a timezone to one without a timezone (with an option to always suppress the warning). This should help users identify bugs and hopefully cause failing reverse dependency checks if other package authors have done it. |
Description
One of the great advantages of
xts
is its flexibility in indexing the observations with dates and so. However, I found a strange behaviour after I change the indexing type of thexts
which IMHO should not happen.Minimal, reproducible example
Let's start with a toy xts and some indexing which works fine:
Now, let's change the index type from POSIXct to Date and we will get the weird behaviour:
Obviously, had I created the xts originally with Date, then there would be no problem:
Therefore, the problem comes from the change of type of index, but I don't think this should happen...
Session Info
The text was updated successfully, but these errors were encountered: