[R] apply() just loops ?
Greg.Snow at imail.org
Wed Nov 12 19:23:27 CET 2008
You may also want to read the Help Desk article in the 8/1 R-News newsletter. It discusses the similarities and differences of *apply and loops and also shows the slowdowns from some common loops (that *apply tend to avoid).
Hope this helps,
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Mark Lyman
> Sent: Wednesday, November 12, 2008 10:44 AM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] apply() just loops ?
> Markus Loecher <mao.loecher <at> gmail.com> writes:
> > Dear R users,
> > I have been diligently using the apply() family in order to avoid
> > for loops and speed up computation.
> > However, when I finally inspected the source code for apply, it
> appears that
> > the core computation is a simple loop as well.
> > What am I missing ? Why the often found advice to use apply() instead
> > loops and the actually observed empirical speedups on many tasks ?
> > Thanks in advance for demystifying,
> > Markus
> Professor Ripley gave the following response to a similar question,
> that I
> believe will answer your question.
> Mark Lyman
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help