[R] R-help
Mike Marchywka
marchywka at hotmail.com
Tue Oct 5 17:26:20 CEST 2010
----------------------------------------
> Date: Tue, 5 Oct 2010 08:18:10 -0700
> From: djmuser at gmail.com
> To: tott_03 at yahoo.com
> CC: r-help at 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
>
>
More information about the R-help
mailing list