[R] Help on making code faster-would C help ?

Benn Fine bennfine at yahoo.com
Thu Jul 20 16:47:40 CEST 2006


Using R on windows....

I have the following code 

for(i in 1:10000) {

draw some random weights

perfom a weighted least squares regression

some simple addition and multiplication
}

The code works fine but is slow. 

I have mingw installed and can dyn.load, although I am
more used to doing this on Unix than Windows.

Would it make sense to re-write the whole thing in
C ? I am vectorizing the random draws-the speed
culprit is looping and the matrix manipulations.

My guess is to use the matrix routines from gls-does
this sound feasible ?

Thanks!



More information about the R-help mailing list