[R] R badly lags matlab on performance?

Dirk Eddelbuettel edd at debian.org
Sat Jan 3 19:33:18 CET 2009


On 3 January 2009 at 23:40, Ajay Shah wrote:
| 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?

Your example does not involve BLAS.  

As for jit and Ra, that was immediate reaction too but I found that jit does
not help on your example.  But I concur fully with what Ben said --- use the
tool that is appropriate for the task at hand.  If your task is running for
loops, Matlab does it faster and you have Matlab, well then you should by all
means use Matlab.

Dirk

-- 
Three out of two people have difficulties with fractions.




More information about the R-help mailing list