On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah <ajays...@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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to