[R] Incrementing a counter in lapply

Gabor Grothendieck ggrothendieck at gmail.com
Tue Mar 14 18:19:10 CET 2006


On 3/14/06, Thomas Lumley <tlumley at u.washington.edu> wrote:
> On Tue, 14 Mar 2006, Gabor Grothendieck wrote:
>
> > On 3/14/06, Thomas Lumley <tlumley at u.washington.edu> wrote:
> >> It is probably worth pointing out here that the R documentation does not
> >> specify the order in which lapply() does the computation.
> >>
> >
> > I suspect that a huge amount of application code takes advantage
> > of this order.
> >
>
> I don't.  The order of evaluation is usually not readily observable. You
> either have to use <<- to modify an external variable or you have to
> produce printed or graphical output where the order matters.
>
> There's probably some examples, but there are some examples of people
> using solve(t(X) %*% W %*% X) %*% W %*% Y to compute regression
> coefficients, too.

By order do you mean that the result is returned in a random order
or that the result is returned in a fixed order but computed it a random
order?




More information about the R-help mailing list