----------------------------------------
> Date: Tue, 5 Oct 2010 08:18:10 -0700
> From: djmu...@gmail.com
> To: tott...@yahoo.com
> CC: r-help@r-project.org
> Subject: Re: [R] R-help
>
> Hi:
>
> This problem is a useful lesson in the power of vectorizing calculations in
> R.
>
> A remanufacturing of your function:
[...]

> The vectorized version is over 200 times faster than the loop. In R,
> vectorization pays
> dividends (sometimes big ones) when the operation is amenable to it. This
> is an
> important lesson to learn when migrating to R from a traditional programming
> language.

Correct me if wrong as I have already demonstrated that I am not that familiar
with R details, but more generally what you have done is relegated inner loops
to internal R code which is presumably optimized native code and doesn't require
an R interpretter to keep executing your "for" or other loop code. This is
well known in java or scripting languages. I'm not just trying to be defensive
( LOL ) but just point out your result is probably more general than you
have stated it. Using R-like approaches or idiosyncratic special functions
can probably be much faster than rolling your own in R code.


>
> HTH,
> Dennis
>
>

                                          
______________________________________________
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