Skip to content

Slow computation in for loop

1 message · Liaw, Andy

#
I don't know if this will help you or not, but might worth a try.  You can
replace the two inner for loops with nested calls to sapply().  For example:
[,1] [,2] [,3] [,4] [,5]
[1,]    7    8    9   10   11
[2,]    8    9   10   11   12
[3,]    9   10   11   12   13
[4,]   10   11   12   13   14
[5,]   11   12   13   14   15

Using sapply() this way is a sneaky way of avoiding explicit for loops, but
whether it actually saves resources, you have to try and see.

HTH,
Andy
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, cont... {{dropped}}