[R] R badly lags matlab on performance?
Wacek Kusnierczyk
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Sat Jan 3 23:15:22 CET 2009
Ajay Shah wrote:
>> 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.
>>
>
> A good chunk of statistical computation involves loops. We are all
> happy R users. I was surprised to see that we are so far from matlab
> in the crucial dimension of performance.
>
>
this list has a tradition of encouraging users to use apply&relatives
instead of for loops (and to use vectorised code instead of both).
compare the following for n = 10^6 and n = 10^7:
x = 1:n
system.time({for (i in 1:n) x[i] = x[i] + 1})
x = 1:n
system.time({x = sapply(x, `+`, 1)})
vQ
More information about the R-help
mailing list