[R] fastest way to multiply each column of a matrix by a single vlaue
jg_liao at yahoo.com
Tue Sep 4 03:48:02 CEST 2001
Let A be a m by n matrix and b a length n vector. What is the fastest
vectorized code for doing
for(j in 1:n) A[, j] <- A[, j]/b[j] ?
B <- matrix( rep(b, m), byrow=T, nrow=m )
I have a program that uses this kind of operation million of times and
I appreciate your input.
Jason G. Liao
Department of Biometry and Epidemiology
Medical University of South Carolina
135 Rutledge Ave., STE 1148, Charleston, SC 29425
phone (843) 876-1114, fax (843) 876-1126
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help