Dear David, Thank you very much for your answer. I am going to try what you propose and compare the two methods.
I have already done what I could to reduce the computation time of the function by using apply functions and by doing most of the calculation on matrices at once to avoid the use of for loops, which I guess is what you call "vectorisation". However I have no idea about what you mean by the "proper use of indexing". Could you please give me more details about that ? Thanks again for your response, Sunelav -- View this message in context: http://r.789695.n4.nabble.com/Use-apply-on-a-function-with-multiple-argument-including-a-matrix-tp3556193p3556475.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.