[R] random numbers selection - simple example

Daniel Nordlund res90sx5 at verizon.net
Wed Jun 6 17:34:28 CEST 2007


> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch]
> On Behalf Of Jenny Barnes
> Sent: Wednesday, June 06, 2007 7:55 AM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] random numbers selection - simple example
> 
> You're all stars - thanks for the replies - I will go ahead and use
> sample...........
> I need to do this about 10,000 times - any suggestions for this or simply put it
> in a loop 10,000 times outputting each time to an array?
> 
> Best Wishes,
> 
> Jenny
> 
> 
> >
> >
> >  use sample(c(0:42), 15, replace=T)
> >
> >hope it helps,
> >kevin

You could try something like the following

s<-matrix(sample(c(0:42), 10000*15, replace=TRUE), 10000, 15)

which will give you a 10000 row matrix with 1 sample of size 15 per row.

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA USA



More information about the R-help mailing list