[R] Choosing a random number between x and y
Bernardo Rangel Tura
tura at centroin.com.br
Tue Feb 10 10:30:31 CET 2009
On Mon, 2009-02-09 at 06:40 -0800, Vie wrote:
> Ive been trying to find a function that will allow me to pull out a number
> between a minimum and maximum threshold.
> I want a random decimal number between, for example, 0 and 0.5 or 0 and 0.7.
> I've been searching everywhere for a function that will allow me to do this
> in R, but I have yet to be successful. Any help would be much appreciated.
> Thanks in advance
I don't understand if you need a only random generation or mixture
random generation, so i will make the 3 examples Using runif
1- Random 10 number Retween 0 and 0.5 runif(10,0,0.5)
2 -Random 20 number Retween 0 and 0.7 runif(20,0,0.7)
3- Random 40 number of mixture two random uniforme random 1 and 2 with
p(random1)= 0.3 and p(random=2) = 0.7
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
More information about the R-help