Thanks for the help.  That explains why my time testing showed no
difference.  Is there any way to speed up the program?  It is unbearably
slow if I increase the number of loops.

Mike


On Wed, Apr 23, 2008 at 6:23 PM, hadley wickham <[EMAIL PROTECTED]> wrote:

> On Wed, Apr 23, 2008 at 4:23 PM, Mike Dugas <[EMAIL PROTECTED]> wrote:
> > The answer to my post is yes (which I just figured out).
> >
>
> Switching from for to apply isn't going to speed up your code.  If you
> carefully read the source code of apply, you'll see the guts of the
> work is done by:
>
>  for (i in 1:d2) {
>        tmp <- FUN(array(newX[, i], d.call, dn.call), ...)
>        if (!is.null(tmp))
>            ans[[i]] <- tmp
>    }
>
> i.e apply uses for internally.  The reason to use apply instead of a
> for loop is so that you can better express the intent of your
> algorithm.
>
> Hadley
>
>
> --
> http://had.co.nz/
>

        [[alternative HTML version deleted]]

______________________________________________
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