I have a 10 by 6 matrix and I'd like to multiply columns 2:6 by column 1, then columns 3:6 by column 2, and so on until I'm left with column 5 \* column 6. The matrix is below.

```
    M12.7 <- matrix(data = 1:60, nrow = 10, ncol = 6)
       [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]    1   11   21   31   41   51
 [2,]    2   12   22   32   42   52
 [3,]    3   13   23   33   43   53
 [4,]    4   14   24   34   44   54
 [5,]    5   15   25   35   45   55
 [6,]    6   16   26   36   46   56
 [7,]    7   17   27   37   47   57
 [8,]    8   18   28   38   48   58
 [9,]    9   19   29   39   49   59
[10,]   10   20   30   40   50   60

```

This should result in 5 matrices for a total of 15 columns. I want to then combine those matrices into a 10 by 15 matrix. I've written a function that sort of gets me there. But I can't apply it to a whole reference matrix, M12.7 in this case. The function is:

```
function(datamatrix, column, colz) { 
   datamatrix[, column] * datamatrix[, (column+1):colz]
}

```

datamatrix in the function is not data.matrix. Any help is greatly appreciated