4
I need to divide the elements of a matrix by the respective average of its column, as I can do this, there is some function to perform this simple operation?
Considering the matrix:
> A <- matrix(1:16, ncol = 4)
> A
[,1] [,2] [,3] [,4]
[1,] 1 5 9 13
[2,] 2 6 10 14
[3,] 3 7 11 15
[4,] 4 8 12 16
And the average of each column in the vector:
> MediacolA <- colMeans(A)
> MediacolA
[1] 2.5 6.5 10.5 14.5