[datatable-help] Convert large matrix directly to data.table

Matthew Dowle mdowle at mdowle.plus.com
Wed Sep 12 16:10:22 CEST 2012


Welcome.

Like this?

> M = matrix(1:12,nrow=3)
> M
     [,1] [,2] [,3] [,4]
[1,]    1    4    7   10
[2,]    2    5    8   11
[3,]    3    6    9   12
> as.data.table(M)
   V1 V2 V3 V4
1:  1  4  7 10
2:  2  5  8 11
3:  3  6  9 12
>

Things like as.* methods are considered standard R, so aren't documented
explicitly.  You can see how it does it by typing
"data.table:::as.data.table.matrix".

If anyone needs that to be faster, it would be easy to port into C, so
please raise a feature request if needed.


> Is there a way to pass a matrix-object directly into the
> data.table-format?
> I couldn't find this functionality being mentioned in the package
> documentation, but maybe there exists a solution already?
>
> Many thanks in advance!
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Convert-large-matrix-directly-to-data-table-tp4642897.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>




More information about the datatable-help mailing list