Multiple functions on multiple columns by group, and create informative column names

后端 未结 5 869
心在旅途
心在旅途 2020-12-16 19:17

How to adjust a data table manipulation so that, besides sum per category of several colums, it would also calculate other functions at the same time such as <

5条回答
  •  鱼传尺愫
    2020-12-16 19:52

    Here's a data.table answer:

    funs_list <- lapply(FunChoice, as.symbol)
    dcast(dt, category~1, fun=eval(funs_list), value.var = Colchoice)
    

    It's super fast and does what you want.

提交回复
热议问题