Re: [R] How can I make this nested loop faster?

2014-05-09 Thread Suzen, Mehmet
Your code is not re-producable. Can you provide a working example using a standard dataset from R? But, you could first try to use compiler package, see ?enableJIT. Another option would be to use doMC/foreach packages if you can run your assignment in the nested loop in parallel, see %dopar%. On

[R] How can I make this nested loop faster?

2014-05-08 Thread Ludwig Hilger
Hello everybody, I have written a nested for-loop, but as length(uc) 170,000, this would take VERY long. I have tried to use sapply or something but I cannot get it to work, I would be happy if someone could point out to write this more efficiently. Thank you all, Ludwig ergsens -

Re: [R] How can I make this nested loop faster?

2014-05-08 Thread William Dunlap
I cannot run your code because not all the variables are defined, but try not doing the nested replacements, rftab$masskg[...] - newValue, in the loop. Instead, pull out masskg as a new stand-along object before the start of the loop and put it back into rftab at the end of the loop. E.g.,