[R] random numbers selection - simple example

Jenny Barnes jmb at mssl.ucl.ac.uk
Wed Jun 6 16:55:06 CEST 2007


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
>
>----- Original Message -----
>From: Jenny Barnes <jmb at mssl.ucl.ac.uk>
>Date: Wednesday, June 6, 2007 10:30 am
>Subject: [R] random numbers selection - simple example
>
>> Dear R-help,
>> 
>> Which random number generator function would you recommend for 
>> simply picking 15 
>> random numbers from the sequence 0-42? I want to use replacement 
>> (so that the 
>> same number could potentially be picked more than once).
>> 
>> I have read the R-help archives and the statistics and computing 
>> book on modern 
>> Applied statistics with S but the advice seems to be for much form 
>> complicated 
>> examples, there must be a simpler way for what I am trying to do?
>> 
>> If anybody can help me I would greatly appreciate your advice and 
>> time,
>> Best Wishes,
>> 
>> Jenny
>> 
>> 
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> Jennifer Barnes
>> PhD student: long range drought prediction 
>> Climate Extremes Group
>> Department of Space and Climate Physics
>> University College London
>> Holmbury St Mary 
>> Dorking, Surrey, RH5 6NT
>> Web: http://climate.mssl.ucl.ac.uk
>> 
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-
>> guide.htmland provide commented, minimal, self-contained, 
>> reproducible code.
>> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jennifer Barnes
PhD student: long range drought prediction 
Climate Extremes Group
Department of Space and Climate Physics
University College London
Holmbury St Mary 
Dorking, Surrey, RH5 6NT
Tel: 01483 204149
Mob: 07916 139187
Web: http://climate.mssl.ucl.ac.uk



More information about the R-help mailing list