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:rsoerum80@hotmail.com] 
Sent: Wednesday, November 12, 2003 9:26 AM
To: r-help@stat.math.ethz.ch
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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

	[[alternative HTML version deleted]]


