[R] generate random number without repetition

Benilton Carvalho bcarvalh at jhsph.edu
Thu Sep 24 00:36:47 CEST 2009


if you want to sample integers in [1, 33K] without replacement:

theSample = sample(33000, 18000)

b

On Sep 23, 2009, at 7:29 PM, phoebe kong wrote:

> Hi all,
>
> I would like to generate ~18K random number from range 1 to ~33K.
>
> I was thinking to use round(runif(18000,1,33000)), however the some  
> random
> numbers generated are repeated.
>
> Do you know a better way?
>
> thanks,
> phoebe
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.




More information about the R-help mailing list