Efficient ways to reshape huge data from long to wide format - similar to dcast

后端 未结 1 1045
天涯浪人
天涯浪人 2020-12-23 21:36

This question pertains to creating \"wide\" tables similar to tables you could create using dcast from reshape2. I know this has been discussed many times before, but my que

相关标签:
1条回答
  • 2020-12-23 22:35

    For n=1e6 the following takes about 10 seconds with plain dcast and about 4 seconds with dcast.data.table:

    library(reshape2)
    
    dcast(z[, sum(price), by = list(c1, c2, c3)], c1 + c2 ~ c3)
    
    # or with 1.8.11
    dcast.data.table(z, c1 + c2 ~ c3, fun = sum)
    
    0 讨论(0)
提交回复
热议问题