Applying combn() function to data frame?

前端 未结 1 1802
傲寒
傲寒 2021-01-27 23:45

so I have a data frame containing certain type of data for different stocks, sample as followed:

Date     RY    TD     BNS...
10-01   2.98   2.29   1.91
10-02            


        
1条回答
  •  情歌与酒
    2021-01-28 00:22

    As suggested by Alistaire, apply can be easily used for this

    apply(df[, -1], 1, function(x) {
         sum(combn(x, 2, prod))
    }
    )
    

    You could also use package parallel and use mcapply* functions to run it in multicore modes

    0 讨论(0)
提交回复
热议问题