[R] Large loops hang?

From: Minimax <minimax_at_hell.org>
Date: Thu, 28 Feb 2008 21:30:45 +0100

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 ?



R-help_at_r-project.org 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. Received on Thu 28 Feb 2008 - 20:47:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Feb 2008 - 02:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive