Skip to content
Prev 138910 / 398513 Next

Warning: matrix by vector division

and you might want to check ?prop.table

 > prop.table(a, 2)
      [,1]      [,2]
[1,]  0.0 0.3333333
[2,]  0.5 0.3333333
[3,]  0.5 0.3333333

or even ?sweep (which will be useful for more complex situations)

 > sweep(a, 2, colSums(a), "/")
      [,1]      [,2]
[1,]  0.0 0.3333333
[2,]  0.5 0.3333333
[3,]  0.5 0.3333333

b
On Mar 7, 2008, at 5:32 PM, Alexey Shipunov wrote: