[R] R badly lags matlab on performance?

Stefan Grosse singularitaet at gmx.net
Sat Jan 3 18:59:29 CET 2009


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.

Another approach is just in time compilation, which would speed up
simple loops. 

There is an interesting entry on R-wiki showing speeding up things:

http://wiki.r-project.org/rwiki/doku.php?id=tips:programming:code_optim2&s=just%20time

hth
Stefan




More information about the R-help mailing list