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 2.96 2.61 2.15
10-03 2.96 2.59 2.09
...
What I want to do is to use combn() function to calculate the sum of the products of all possible combinations of 2 stocks. I know how to do it with single values using, for example:
df <- c(2.98, 2.29, 1.91)
sum(combn(df, 2, prod))
But since now I have a data frame with daily data for each symbol, how do I apply the above function and output the sum results as a data list corresponding to each date?
Thanks