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.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to