Re: [R] code optimisation problem

2012-11-28 Thread Suzen, Mehmet
nal Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >> Behalf >> Of cbe...@tajo.ucsd.edu >> Sent: Tuesday, November 27, 2012 4:53 PM >> To: r-h...@stat.math.ethz.ch >> Subject: Re: [R] code optimisation problem >>

Re: [R] code optimisation problem

2012-11-27 Thread William Dunlap
ay, November 27, 2012 4:53 PM > To: r-h...@stat.math.ethz.ch > Subject: Re: [R] code optimisation problem > > Rui Barradas writes: > > > Hello, > > > > Package 'compiler' is good at optimizing for loops. Try the following. > > > > Or vectori

Re: [R] code optimisation problem

2012-11-27 Thread cberry
Rui Barradas writes: > Hello, > > Package 'compiler' is good at optimizing for loops. Try the following. > Or vectorize the function > system.time(f1(x,10)) user system elapsed 5.010.005.00 > system.time(f1.c(x,10)) user system elapsed 1.920.001.91 > f2 <- func

Re: [R] code optimisation problem

2012-11-27 Thread Rui Barradas
Hello, Package 'compiler' is good at optimizing for loops. Try the following. #install.packages('compiler') library(compiler) f1.c <- cmpfun(f1) N <- 1e6 x <- rnorm(N) system.time(f1(x, 10)) user system elapsed 6.770.066.83 system.time(f1.c(x, 10)) user system elapsed 2.5