[R] R badly lags matlab on performance?

Ajay Shah ajayshah at mayin.org
Sat Jan 3 19:10:59 CET 2009


On Sat, Jan 03, 2009 at 06:59:29PM +0100, Stefan Grosse wrote:
> On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah <ajayshah at mayin.org> wrote:
> 
> AS> system.time(for (i in 1:10000000) {a[i] <- a[i] + 1})
> 
> AS> I wonder what we're doing wrong!
> 
> it is no secret that R does badly with loops. Thats why it is
> recommended to use vectorized operations.

But there's a big difference even on the vectorised version: a <- a +
1. Why should that be? Both systems should merely be handing down to
the BLAS. The (stock) R install has a less carefully setup BLAS as
compared with the (stock) matlab install?

-- 
Ajay Shah                                      http://www.mayin.org/ajayshah  
ajayshah at mayin.org                             http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.




More information about the R-help mailing list