-
Notifications
You must be signed in to change notification settings - Fork 986
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
FR: setDT
for matrices
#6565
Comments
I don't think that makes sense. A data.frame and a data.table are lists. A matrix is a very different data structure. How often do you create data.tables from matrices that are so large that you need to avoid a deep copy? |
@ecoRoland2 Leaving implementation difficulties aside, I often do simulations using Rcpp and matrices, as matrices are much more intuitive to work with on the C++ side. The outputs are also matrices, sometimes several GB each. Having a more efficient way to convert a matrix to a data.table on the R side would be nice. So, the request by @iago-pssjd is not outrageous, and there are real-life use cases, albeit perhaps rare. |
I think you'll have to do this yourself, like
this could conceivably be wrapped into a data.table export, though I worry about the troubles of creating a column-by-column by-reference copy of an array. it will definitely not be part of setDT, the semantics are way too different. |
AFAIR there is a PR for a fast matrix to data.table conversion (edit: it is #4144) |
Currently,
setDT
accepts as main argumentWould it have sense to accept a matrix too instead of asignment
dt <- as.data.table(matrix(...))
?The text was updated successfully, but these errors were encountered: