Re: [R] simple matrix division.

2006-09-02 Thread Prof Brian Ripley
On Sat, 2 Sep 2006, Alexander Nervedi wrote: > Hi > > I have > > >x<-matrix(c(1,2,3,4), ncol = 2) > >x > [,1] [,2] > [1,]13 > [2,]24 > > I'd like these two be divided by their column totals. so 1/3 and 2/3 and 3/7 > and 4/7. The obvious > >x/colSums(x) > [,1]

Re: [R] simple matrix division.

2006-09-02 Thread Gabor Grothendieck
Try: prop.table(x, 2) On 9/2/06, Alexander Nervedi <[EMAIL PROTECTED]> wrote: > Hi > > I have > > >x<-matrix(c(1,2,3,4), ncol = 2) > >x > [,1] [,2] > [1,]13 > [2,]24 > > I'd like these two be divided by their column totals. so 1/3 and 2/3 and 3/7 > and 4/7. The obvious > >x/c

[R] simple matrix division.

2006-09-02 Thread Alexander Nervedi
Hi I have >x<-matrix(c(1,2,3,4), ncol = 2) >x [,1] [,2] [1,]13 [2,]24 I'd like these two be divided by their column totals. so 1/3 and 2/3 and 3/7 and 4/7. The obvious >x/colSums(x) [,1] [,2] [1,] 0.333 1.000 [2,] 0.2857143 0.5714286 gives me the wro