I'm not sure what you are trying to prove with that example - the loopless versions are massively faster, no?
I don't disagree that loops are sometimes unavoidable, and I suppose sometimes loops can be faster when the non-loop version e.g. breaks your memory budget, or performs tons of needless computations. But I think avoiding for loops whenever you can is a good rule of thumb in R coding. -- View this message in context: http://r.789695.n4.nabble.com/For-calculation-is-so-slow-tp4630830p4630897.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.