-
Notifications
You must be signed in to change notification settings - Fork 1k
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
as.xts.data.table is limited to numeric data types, but this is not an xts limitation #5268
Comments
i was going to work on a pr to essentially just do either: which i think is the proper way to handle the conversion. |
Best option imho would be to establish type counts via |
wont mode based column filtering still be a potential breaking change? shouldn't the caller really be responsible for subsetting which columns to include using one option would be to add a |
There is also a significant performance gain to using > str(z)
Classes ‘data.table’ and 'data.frame': 19911744 obs. of 6 variables:
$ index : POSIXct, format: "1962-01-02" "1962-01-03" "1962-01-04" "1962-01-05" ...
$ Open : num 0.423 0.422 0.424 0.419 0.411 ...
$ High : num 0.423 0.43 0.431 0.422 0.418 ...
$ Low : num 0.415 0.422 0.419 0.4 0.406 ...
$ Close : num 0.415 0.424 0.419 0.411 0.412 ...
$ Volume: num 704396 1420820 1822013 1760777 947213 ...
- attr(*, ".internal.selfref")=<externalptr> > microbenchmark(as.xts(setDF(z[,-1L]), order.by = z[[1L]]),
+ xts(setDF(z[,-1L]), order.by = z[[1L]]),
+ xts(as.matrix(z[,-1L]), order.by = z[[1L]]), times = 5)
Unit: seconds
expr min lq mean median uq max neval
as.xts(setDF(z[, -1L]), order.by = z[[1L]]) 12.374819 16.449329 17.465670 16.517783 18.019016 23.96741 5
xts(setDF(z[, -1L]), order.by = z[[1L]]) 11.876490 14.277099 17.339480 19.085982 19.989391 21.46844 5
xts(as.matrix(z[, -1L]), order.by = z[[1L]]) 4.237925 4.315352 6.064066 4.817026 5.817695 11.13233 5 |
to disambiguate the issues, this is what i see:
|
xts
allows columns to have any type, as long as the columns are all the same type (as its really a matrix under the hood)for example, you can have character columns:
xts(x = cbind(letters, LETTERS), order.by = Sys.Date() + (1:26))
logicals:
xts(x = c(T,F), order.by = Sys.Date() + (1:2))
as.xts.data.table
currently only allows conversion for numeric columns. it should follow the same rules asxts
and support any typeThe text was updated successfully, but these errors were encountered: