[R] Is there a faster way to do this?
Márcio Resende
mresendeufv at yahoo.com.br
Fri Mar 26 02:14:49 CET 2010
Hi guys, I am still learning R, and not well familiar with all the apply
functions.
I am trying to find faster alternatives to replace the for cycle.
Is there a faster way to do the example below?
nm <- 1000
b <- matrix (rnorm (5000, 0, 1), nrow = 500, ncol = nm)
a <- matrix (0, nm, nm)
for (i in 1 : nm) {
for (j in 1 : nm) {
if ( j == i) {
next }
a[i, j] <- t (b [, i]) %*% b[, j]
}
}
thanks
--
View this message in context: http://n4.nabble.com/Is-there-a-faster-way-to-do-this-tp1691601p1691601.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list