Open dereckmezquita opened 2 years ago
Hi, thank you for code and proposal. Convert to/from matrix by reference is not possible, therefore set* should be avoided. DF is a collection of C arrays, each column is a separate array. Matrix is a single C array, where attributes defines it's shape. I think it is better to improve existing methods rather than adding new functions.
Could I offer some of these functions as helpers which would cut down on some of the verbosity of writing code which uses
data.table
?I'll be using this data as an example dataset:
Setting a
matrix
by referenceI find myself often working with
data.frame
s andmatrix
type objects, we currently have asetDF
function but no "setMatrix"/"setMT" equivalent.to.X
family of functions but move a column torownames
Here I propose a family of functions which would allow one to convert to a certain class,
data.frame
ormatrix
, but move one of the columns to itsrownames
.This is useful because again I find myself working with
data.frame
s a lot when interacting withbase R
/packages but sincedata.table
doesn't allowrownames
I have to keep this information as a column and then move it as such:I propose to simplify this to a single function call which could move the column to the
rownames
of the resulting object.Convert to a
data.frame
Thus converting to a
data.frame
withrownames
is simplified to:Convert to a
matrix
sessionInfo()