On Mon, 2009-02-09 at 06:40 -0800, Vie wrote: > Hi, > > 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
Hi Vie 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 ifelse(runif(40)>.3,runif(40,0,0.7),runif(40,0,0.5)) -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil ______________________________________________ R-help@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.