best way to transpose data.table

后端 未结 6 1915
渐次进展
渐次进展 2020-11-30 22:18

[UPDATE: there is now a native transpose() function in data.table package]

I often need to transpose a data.table, every time

6条回答
  •  萌比男神i
    2020-11-30 22:34

    The current docs show a builtin transpose method.

    Specifically, you can do:

    transpose(mydata, keep.names = "col", make.names = "col0")
    ##     col row1 row2 row3
    ## 1: col1   11   21   31
    ## 2: col2   12   22   32
    ## 3: col3   13   23   33
    

提交回复
热议问题