[R] Large loops hang?

Minimax minimax at hell.org
Thu Feb 28 21:30:45 CET 2008


Dear useRs,

Suppose we have loop:

res <- c()
for (i in 1:100000) {
	x <- rnorm(2)
	res <- c(res,x[2]-x[1])
	}

and this loop for 10^5 cases runs about - for example 5 minutes.

When I add one zero (10^6) this loop will not end overnight but probably
hangs. This occurs regardless of calculated statistics in such 
simulation, always above 10^5 times. Nested loops do not help.

Any suggestions for collecting larger amount of Monte Carlo data ?

Regards

Minimax



More information about the R-help mailing list