You can break out of a loop (see ?break), but, if I understand correctly what you want, why not just use sample(max, N)?
John
At 02:26 PM 11/12/2003 +0000, Ragnhild S�rum wrote:
Hi,
I'm in this situation:
I what to generate N random numbers(integer) that are different from each other.
One suggestion:
tabel <- rep(NULL, N) for (i in 1:N){ temp <- as.integer(runif(1,1,max)) if(temp in tabel) { repeat (?) (temp <- as.integer(runif(i,i,max))) until (?) ((temp in tabel) ==FALSE) } else{ tabel[i] <- temp}
I can't use repeat/until - don't exist.... Any suggestions?
----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: [EMAIL PROTECTED] phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
