Re: [R] Add grand mean to every entry in a matrix

2009-07-13 Thread Gavin Simpson
On Mon, 2009-07-13 at 09:06 +, Tom Liptrot wrote: > Hi, > > I have a matrix: > > mymat <- matrix(runif(10*4), ncol=4) > > I wish to subtract the column means, down the colums, subtract the row > means from the rows and add back the grand mean - all the means should > be the means of mymat ra

[R] Add grand mean to every entry in a matrix

2009-07-13 Thread Tom Liptrot
Hi, I have a matrix: mymat <- matrix(runif(10*4), ncol=4) I wish to subtract the column means, down the colums, subtract the row means from the rows and add back the grand mean - all the means should be the means of mymat rather than of the new matrix. How can I do this? Any help much appr