See ?sample which has a default of replace = FALSE.
Usage:
sample(x, size, replace = FALSE, prob = NULL)
> N<-10
> sample(1:(2*N),N)
[1] 1 14 11 3 19 8 4 7 18 17
bob
-----Original Message-----
From: Ragnhild S�rum [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 12, 2003 9:26 AM
To: [EMAIL PROTECTED]
Subject: [R] repeat until function
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?
Thanks
*Ragnhild*
_________________________________________________________________
MSN Messenger http://www.msn.no/messenger Den korteste veien mellom deg og
dine venner
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[[alternative HTML version deleted]]
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help