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

Matthew Dowle mdowle at mdowle.plus.com
Thu Sep 13 13:53:22 CEST 2012


or, to avoid the copy of as.data.table(), then a faster but more raw way is :

setattr(as.data.frame(M,stringsAsFactors=FALSE), "class", "data.table")

which, if you need data.frame inheritence to work, you'll have to remember
to include :

setattr(as.data.frame(M,stringsAsFactors=FALSE), "class",
c("data.frame","data.table"))



>
> Please add a FR to add stringsAsFactors to as.data.table.matrix method,
> and may as well capture feature request to port that to C, at the same
> time.
>
> In meatime, given M your character matrix :
>
> as.data.table(as.data.frame(M,stringsAsFactors=FALSE))
>
>
>> Hi Matthew,
>>
>> First of all thank you for the quick response.  Is there a way to
>> include
>> a
>> statement like stringsAsFactors into data.table:::as.data.table.matrix?
>>
>> My 10mil by 20 matrices are of mode character, but the columns shouldn't
>> be
>> coerced into factors as is the default behaviour....
>>
>>
>>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/Convert-large-matrix-directly-to-data-table-tp4642897p4643008.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
>>
>
>
> _______________________________________________
> 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