Skip to content
Prev 170654 / 398506 Next

Alternate to for-loop

If the goal is to "look" professional, then
'replicate' probably suits.  If the goal is to
compute as fast as possible, then that isn't
the case because 'replicate' is really a 'for'
loop in disguise and there are other ways.

Here's one other way:

function (size, replicates, distfun, ...)
{

        colMeans(array(distfun(size * replicates, ...), c(size, 
replicates)))
}



Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of "The R Inferno" and "A Guide for the Unwilling S User")
Uwe Ligges wrote: