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]
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
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