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
>>
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
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
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
4 matches
Mail list logo