[R] Too slow to execute!

jim holtman jholtman at gmail.com
Sun Apr 29 19:43:58 CEST 2007


Yet another way of doing it:

> system.time({
+     x <- replicate(100000, (rnorm(20) - 20) / 20)
+ })
[1] 3.44 0.06 3.71   NA   NA
>
> str(x)
 num [1:20, 1:100000] -1.041 -0.980 -0.987 -1.062 -1.012 ...
>

On 4/29/07, Usman Shehu <ugulumbe at yahoo.co.uk> wrote:
> Greetings,
> I have the following simple function but what worries me is that it takes about  5 or more minutes to execute. My machine runs on windows with 1.8GHz and 256 Ram.
> > Re=NULL
> > for(i in 1:100000){
> + x=rnorm(20)
> + Re[i]=(x-2*10)/20
> + Re
> + }
> I would appreciate any help on how to make it faster.
>
> Usman
>
>
>
>
>      ___________________________________________________________
>
> now.
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list