[R] Avoiding loop

Filoche pmassicotte at hotmail.com
Mon Apr 18 18:06:18 CEST 2011


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,
Phil

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



More information about the R-help mailing list