[R] Choosing a random number between x and y

Tony Breyal tony.breyal at googlemail.com
Mon Feb 9 20:17:25 CET 2009


Hi Vie,

Something like the following should be fine:

## R Start...
> n<-1
> my.min <- 0
> my.max <- 0.7
> runif(n, my.min, my.max)
[1] 0.01145260
## R end.

see ?runif for details. Hope that helps a little,
Tony Breyal

On 9 Feb, 14:40, Vie <wxv... at bham.ac.uk> 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
>
> --
> View this message in context:http://www.nabble.com/Choosing-a-random-number-between-x-and-y-tp2191...
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list