You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have stumbled across what I believe to be a bug in as.data.table.xts(foo) where the index values, which should correspond to timestamps for the observations sometimes come out simply as the row numbers. I have looked on this repository and SO, but I found nothing on this topic.
From my experimentation this occurs when a column in foo has the name "x", it seems that the number of columns do not affect this bug, and the order of the columns do not change the result either.
I have written a little example that should sufficiently show the expected and the misbehavior and in which cases these occur.
I have implemented a simple fix by just using set() instead of "[.data.table" to assign the index value to the output data table in as.data.table.xts(). The output after the fix is:
This is just a work-around. I can't quite figure out what actually causes this behavior, but I think it has something to do with line 1298 in data.table.R , but I am not 'into' the code enough to be sure.
If I change the jsub from zoo::index(x) to return(x) using the str2lang() function, I get an integer 1:10, I would expect to get the original xts object. I think this is somewhat related to point 2.13 in the FAQ, but I feel this is more of a bug. Otherwise, somewhere this behavior should be documented?
I hope I have provided enough information to be helpful. If the workaround is deemed acceptable, I can create a PR with the fix and a test or two.
The text was updated successfully, but these errors were encountered:
I have stumbled across what I believe to be a bug in
as.data.table.xts(foo)
where the index values, which should correspond to timestamps for the observations sometimes come out simply as the row numbers. I have looked on this repository and SO, but I found nothing on this topic.From my experimentation this occurs when a column in
foo
has the name"x"
, it seems that the number of columns do not affect this bug, and the order of the columns do not change the result either.I have written a little example that should sufficiently show the expected and the misbehavior and in which cases these occur.
I have implemented a simple fix by just using
set()
instead of"[.data.table"
to assign the index value to the output data table inas.data.table.xts()
. The output after the fix is:As shown it now gives the correct output.
This is just a work-around. I can't quite figure out what actually causes this behavior, but I think it has something to do with line 1298 in data.table.R , but I am not 'into' the code enough to be sure.
If I change the
jsub
fromzoo::index(x)
toreturn(x)
using thestr2lang()
function, I get an integer1:10
, I would expect to get the originalxts
object. I think this is somewhat related to point 2.13 in the FAQ, but I feel this is more of a bug. Otherwise, somewhere this behavior should be documented?I hope I have provided enough information to be helpful. If the workaround is deemed acceptable, I can create a PR with the fix and a test or two.
The text was updated successfully, but these errors were encountered: