[R] Avoiding loop

From: Filoche <pmassicotte_at_hotmail.com>
Date: Mon, 18 Apr 2011 09:06:18 -0700 (PDT)

Hi everyone.

I'm using matrix product such as :

#Generate some data

NCols = 5
NRows = 5
A = matrix(runif(NCols*NRows), ncol=NCols) B = matrix(runif(NCols*NRows), ncol=NCols)

#First calculation

R = A%*%B

for(i in 1:100)

        R = R%*%B

I would like to know if it was possible to avoid the loop by using something like mapply or anything else.

Tx in advance,

View this message in context: http://r.789695.n4.nabble.com/Avoiding-loop-tp3457963p3457963.html
Sent from the R help mailing list archive at Nabble.com.

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 18 Apr 2011 - 16:16:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 18 Apr 2011 - 18:00:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive