[R] Odp: Programming: loop versus vector oriented

Jan private jrheinlaender at gmx.de
Fri Sep 17 12:43:40 CEST 2010


Hello Petr,

> but I think this is how your code really works. Did you try it?

it does, but the R documentation says somewhere:
"Warning: for() loops are used in R code much less often than in
compiled languages. Code that takes a `whole object' view is likely to
be both clearer and faster in R."

So I am wondering in what way the "whole object view" could be applied
to my function.

Best regards,
	Jan

> > The function should work on the nth elements of the two input vectors
> > and put the result into the nth element of the output vector. So it
> > would work like c <- a + b, only instead of '+' there are more complex
> > calculations.



More information about the R-help mailing list