Convert a data frame to a data.table without copy
This is available from v1.9.0+. From NEWS:
o Following this S.O. post, a function
setDT
is now implemented that takes alist
(named and/or unnamed),data.frame
(ordata.table
) as input and returns the same object as adata.table
by reference (without any copy). See?setDT
examples for more.
This is in accordance with data.table
naming convention - all set*
functions modifies by reference. :=
is the only other that also modifies by reference.
require(data.table) # v1.9.0+
setDT(data) # converts data which is a data.frame to data.table *by reference*
See history for older (now outdated) answers.