Is there a better way to express operations between matrices and column vectors than transposing the matrix twice?

This is the kind of thing I'm talking about:

m = matrix(1:20, 3, 4)
v = colSums(m)

t(t(m) / v)   ## <--  kinda ugly, ain't it?

I thought of converting the column vector to a matrix:

m / matrix(v, nrow = nrow(m), ncol = length(v), byrow = TRUE)

But that seems even worse.

Thanks!
Rob Steele

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to